secp256k1-zkp node package for MW.
npm install secp256k1-zkpThis library is under development, and, like the secp256k1-zkp C library it depends on, this is a research effort to determine an optimal API for end-users of the mimblewimble ecosystem.
`` bash`
npm install secp256k1-zkp
`bash`
yarn add secp256k1-zkp
PromiseLike.<ArrayBuffer>create random sha256 Buffer
BufferTakes any number (native number, BN, or string) and
converts it to uInt64T (64-bit BE Buffer) suitable for
use by the C++ bindings.
* Secp
* new Secp(opts)
* .secretKeyZero() ⇒ Buffer
* .secretKeyCreate(input) ⇒ Buffer
* .secretKeyGenerate() ⇒ Buffer
* .secretKeyVerify(key) ⇒ boolean
* .secretKeyAdd(secretKey1, secretKey2) ⇒ Buffer
* .secretKeymul(secretKey1, secretKey2) ⇒ Buffer
* .pubKeyZero() ⇒ Buffer
* .pubKeyFromSecretKey(secretKey) ⇒ Buffer
* .pubKeyFromAddingPubKeys(pubKeys) ⇒ Buffer
* .pubKeyIsValid(pubKey) ⇒ boolean
* .pubKeyIsZero(pubKey) ⇒ boolean
* [.pubKeySerialize(pubKey, [compress])](#Secp+pubKeySerialize) ⇒ Buffer
* .pubKeyParse(buffer) ⇒ Buffer
* .keyPairGenerate() ⇒ Object
* .sign(msg, secretKey) ⇒ Buffer
* .verify(sig, msg, pubKey) ⇒ boolean
* .signatureSerialize(sig) ⇒ Buffer
* .signatureParse(buffer) ⇒ Buffer
* [.commit(value, [blind])](#Secp+commit) ⇒ Buffer
* .blindSwitch(value, blind) ⇒ Buffer
* [.commitSum([positives], [negatives])](#Secp+commitSum) ⇒ Buffer
* [.verifyCommitSum([positives], [negatives])](#Secp+verifyCommitSum) ⇒ boolean
* [.blindSum([positives], [negatives])](#Secp+blindSum) ⇒ Buffer
* .commitmentToPubKey(commitment) ⇒ Buffer
* .commitmentSerialize(commitment) ⇒ Buffer
* .commitmentParse(buffer) ⇒ Buffer
* .verifyFromCommit(msg, sig, commitment) ⇒ boolean
* .bulletProofVerify(commitment, rangeProof, extraData) ⇒ boolean
* .bulletProofVerifyMulti(commitments, rangeProofs, extraData) ⇒ boolean
* [.bulletProofCreate(amount, secretKey, nonce, extraData, [msg])](#Secp+bulletProofCreate) ⇒ Buffer
* .bulletProofRewind(commitment, nonce, extraData, rangeProof) ⇒ Buffer
* .aggsigCreateSecnonce() ⇒ Buffer
* .aggsigSignSingle(msg, secretKey, pubKeySum) ⇒ Buffer
* .aggsigSignFromSecretKey(secretKey, msg, blindSum) ⇒ Buffer
* .aggsigCalculatePartialSig(secretKey, secNonce, nonceSum, pubKeySum, msg) ⇒ Buffer
* .aggsigVerifySingle(sig, msg, pubNonce, pubKey, pubKeyTotal, extraPubKey, isPartial) ⇒ Buffer
* .aggsigVerifyPartialSig(sig, pubNonceSum, pubKey, pubKeySum, msg) ⇒ Buffer
* .aggsigVerifySingleFromCommit(sig, msg, commit) ⇒ Buffer
* .aggsigVerifyCompletedSig(sig, pubKey, pubKeySum, msg) ⇒ Buffer
* .aggsigAddSignatures(partSigs, nonceSum) ⇒ Buffer
| Param | Type | Default |
| --- | --- | --- |
| opts | Object | |
| [opts.sign] | boolean | true |
| [opts.verify] | boolean | true |
Kind: instance method of Secp
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| input | Buffer \| string |
Kind: instance method of Secp
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| key | Buffer |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| secretKey1 | Buffer |
| secretKey2 | Buffer |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| secretKey1 | Buffer |
| secretKey2 | Buffer |
Kind: instance method of Secp
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| secretKey | Buffer |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| pubKeys | Array.<Buffer> |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| pubKey | Buffer |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| pubKey | Buffer |
Kind: instance method of Secp
| Param | Type | Default |
| --- | --- | --- |
| pubKey | Buffer | |
| [compress] | boolean | true |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| buffer | Buffer |
and pubKeyFromSecretKeyKind: instance method of Secp
$3
Constructs a signature for msg using the secret key secretKey and RFC6979 nonceKind: instance method of Secp
| Param | Type |
| --- | --- |
| msg | Buffer |
| secretKey | Buffer |
$3
Checks that sig is a valid ECDSA signature for msg using the public
key pubKey.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| sig | Buffer |
| msg | Buffer |
| pubKey | Buffer |
$3
Serializes a signature.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| sig | Buffer |
$3
Parses a signature.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| buffer | Buffer |
$3
Creates a pedersen commitment from a value and a blinding factorKind: instance method of Secp
| Param | Type |
| --- | --- |
| value | number |
| [blind] | Buffer |
$3
Computes blinding factor for switch commitment.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| value | number |
| blind | Buffer |
$3
Computes the sum of multiple positive and negative pedersen commitments.Kind: instance method of Secp
| Param | Type | Default |
| --- | --- | --- |
| [positives] | Array.<Buffer> | [] |
| [negatives] | Array.<Buffer> | [] |
$3
Taking arrays of positive and negative commitments as well as an
expected excess, verifies that it all sums to zero.Kind: instance method of Secp
| Param | Type | Default |
| --- | --- | --- |
| [positives] | Array.<Buffer> | [] |
| [negatives] | Array.<Buffer> | [] |
$3
Computes the sum of multiple positive and negative blinding factors.Kind: instance method of Secp
| Param | Type | Default |
| --- | --- | --- |
| [positives] | Array.<Buffer> | [] |
| [negatives] | Array.<Buffer> | [] |
$3
Retrieves pubKey from commit.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| commitment | Buffer |
$3
Serializes commitment.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| commitment | Buffer |
$3
Parses a commitment.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| buffer | Buffer |
$3
Verify commitment.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| msg | Buffer |
| sig | Buffer |
| commitment | Buffer |
$3
Verify with bullet proof that a committed value is positive.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| commitment | Buffer |
| rangeProof | Buffer |
| extraData | Buffer |
$3
Verify with bullet proof that a committed value is positive.Kind: instance method of Secp
| Param | Type |
| --- | --- |
| commitments | Buffer |
| rangeProofs | Array.<Buffer> |
| extraData | Buffer |
$3
Create a bulletproof.
The blinding factor for commitment should be secretKey.Kind: instance method of Secp
| Param | Type | Default |
| --- | --- | --- |
| amount | number | |
| secretKey | Buffer | |
| nonce | Buffer | |
| extraData | Buffer | |
| [msg] | Buffer | Buffer.alloc(16, 0) |
$3
Rewind a rangeProof to retrieve the amountKind: instance method of Secp
| Param | Type |
| --- | --- |
| commitment | number |
| nonce | number |
| extraData | number |
| rangeProof | number |
$3
Creates a new secure nonce (as a SecretKey), guaranteed to be usable during
aggsig creation.Kind: instance method of Secp
$3
Simple signature (nonce will be created).Kind: instance method of Secp
| Param | Type |
| --- | --- |
| msg | Buffer |
| secretKey | Buffer |
| pubKeySum | Buffer |
$3
Calculates a signature for msg given the secretKey and an optional blindSumKind: instance method of Secp
| Param | Type |
| --- | --- |
| secretKey | Buffer |
| msg | Buffer |
| blindSum | Buffer |
$3
Calculates a partial signature given the signer's secure key,
the sum of all public nonces and (optionally) the sum of all public keys.Kind: instance method of Secp
| Param | Type | Description |
| --- | --- | --- |
| secretKey | Buffer | The signer's secret key |
| secNonce | Buffer | The signer's secret nonce (the public version of which was added to the
nonceSum total) |
| nonceSum | Buffer | The sum of the public nonces of all signers participating in the full signature. This value is encoded in e. |
| pubKeySum | Buffer | (Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e. |
| msg | Buffer | The message to sign. |$3
Single-Signer (plain old Schnorr, sans-multisig) signature verificationKind: instance method of Secp
Returns: Buffer - - Signature on success
| Param | Type | Description |
| --- | --- | --- |
| sig | Buffer | The signature |
| msg | Buffer | the message to verify |
| pubNonce | Buffer | if not null overrides the public nonce used to calculate e |
| pubKey | Buffer | the public key |
| pubKeyTotal | Buffer | The total of all public keys (for the message in e) |
| extraPubKey | Buffer | if not null, subtract this pubKey from sG |
| isPartial | boolean | whether this is a partial sig, or a fully-combined sig |
$3
Verifies a partial signature from a public key. All nonce and public
key sum values must be identical to those provided in the call to
[calculate_partial_sig].Kind: instance method of Secp
| Param | Type | Description |
| --- | --- | --- |
| sig | Buffer | The signature to validate, created via a call to [
calculate_partial_sig`] |Buffer | The sum of the public nonces of all signers participating in the full signature. This value is encoded in e. |Buffer | Corresponding Public Key of the private key used to sign the message. |Buffer | (Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e. |Buffer | The message to verify. |Kind: instance method of Secp
| Param | Type | Description |
| --- | --- | --- |
| sig | Buffer | The Signature to verify |
| msg | Buffer | The message to sign. |
| commit | Buffer | The commitment to verify. The actual public key used during verification is derived from this commit. |
Kind: instance method of Secp
| Param | Type | Description |
| --- | --- | --- |
| sig | Buffer | The Signature to verify |
| pubKey | Buffer | Corresponding Public Key of the private key used to sign the message. |
| pubKeySum | Buffer | (Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e. Must be the same value as when the signature was created to verify correctly. |
| msg | Buffer | The message to verify. |
Kind: instance method of Secp
| Param | Type |
| --- | --- |
| partSigs | Buffer |
| nonceSum | Buffer |
BufferBufferBufferPromiseLike.<ArrayBuffer>Kind: global function
| Param | Type |
| --- | --- |
| v | string |
BufferKind: global function
| Param | Type | Description |
| --- | --- | --- |
| num | number | number to convert. |