navio-blsct
Version:
TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.
36 lines (30 loc) • 819 B
text/typescript
import {
fromTxKeyToSpendingKey,
fromTxKeyToViewKey
} from '../blsct'
import { Scalar } from '../scalar'
/** Represents a tx key. A tx key is a Scalar and introduces no new functionality; it serves purely as a semantic alias. Both SpendingKey and ViewKey are exclusively derived from a TxKey.
*
* Examples:
* ```ts
* const { Scalar, ChildKey } = require('navio-blsct')
* const s = Scalar.random()
* const ck = new ChildKey(s)
* const tk = ck.toTxKey()
* tk.toSpendingKey()
* tk.toViewKey()
* ```
*/
export class TxKey extends Scalar {
constructor(obj?: any) {
super(obj)
}
toSpendingKey(): Scalar {
const obj = fromTxKeyToSpendingKey(this.value())
return new Scalar(obj)
}
toViewKey(): Scalar {
const obj = fromTxKeyToViewKey(this.value())
return new Scalar(obj)
}
}