1.0.2 • Published 5 years ago

secp256k1-zkp v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

secp256k1-zkp

Build Status NPM

This 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.

Installation

npm

npm install secp256k1-zkp

yarn

yarn add secp256k1-zkp

Classes

Constants

Functions

Secp

Kind: global class

new Secp(opts)

ParamTypeDefault
optsObject
opts.signbooleantrue
opts.verifybooleantrue

secp.secretKeyZero() ⇒ Buffer

Creates an zero secret key.

Kind: instance method of Secp

secp.secretKeyCreate(input) ⇒ Buffer

Creates a secret key.

Kind: instance method of Secp

ParamType
inputBuffer | string

secp.secretKeyGenerate() ⇒ Buffer

Creates a new random secret key

Kind: instance method of Secp

secp.secretKeyVerify(key) ⇒ boolean

Verifies validity of a secret key.

Kind: instance method of Secp

ParamType
keyBuffer

secp.secretKeyAdd(secretKey1, secretKey2) ⇒ Buffer

Adds two secretKeys to create a new secretKey

Kind: instance method of Secp

ParamType
secretKey1Buffer
secretKey2Buffer

secp.secretKeymul(secretKey1, secretKey2) ⇒ Buffer

Adds two secretKeys to create a new secretKey

Kind: instance method of Secp

ParamType
secretKey1Buffer
secretKey2Buffer

secp.pubKeyZero() ⇒ Buffer

Creates an invalid zero public key.

Kind: instance method of Secp

secp.pubKeyFromSecretKey(secretKey) ⇒ Buffer

Creates a new public key from a secret key.

Kind: instance method of Secp

ParamType
secretKeyBuffer

secp.pubKeyFromAddingPubKeys(pubKeys) ⇒ Buffer

Creates a new public key from the sum of the public keys.

Kind: instance method of Secp

ParamType
pubKeysArray.<Buffer>

secp.pubKeyIsValid(pubKey) ⇒ boolean

Determine if a public key is valid.

Kind: instance method of Secp

ParamType
pubKeyBuffer

secp.pubKeyIsZero(pubKey) ⇒ boolean

Determine if a public key is zero.

Kind: instance method of Secp

ParamType
pubKeyBuffer

secp.pubKeySerialize(pubKey, compress) ⇒ Buffer

Serializes a public key.

Kind: instance method of Secp

ParamTypeDefault
pubKeyBuffer
compressbooleantrue

secp.pubKeyParse(buffer) ⇒ Buffer

Parses a public key.

Kind: instance method of Secp

ParamType
bufferBuffer

secp.keyPairGenerate() ⇒ Object

Generates a random keyPair. Convenience function for secretKeyGenerate and pubKeyFromSecretKey

Kind: instance method of Secp

secp.sign(msg, secretKey) ⇒ Buffer

Constructs a signature for msg using the secret key secretKey and RFC6979 nonce

Kind: instance method of Secp

ParamType
msgBuffer
secretKeyBuffer

secp.verify(sig, msg, pubKey) ⇒ boolean

Checks that sig is a valid ECDSA signature for msg using the public key pubKey.

Kind: instance method of Secp

ParamType
sigBuffer
msgBuffer
pubKeyBuffer

secp.signatureSerialize(sig) ⇒ Buffer

Serializes a signature.

Kind: instance method of Secp

ParamType
sigBuffer

secp.signatureParse(buffer) ⇒ Buffer

Parses a signature.

Kind: instance method of Secp

ParamType
bufferBuffer

secp.commit(value, blind) ⇒ Buffer

Creates a pedersen commitment from a value and a blinding factor

Kind: instance method of Secp

ParamType
valuenumber
blindBuffer

secp.blindSwitch(value, blind) ⇒ Buffer

Computes blinding factor for switch commitment.

Kind: instance method of Secp

ParamType
valuenumber
blindBuffer

secp.commitSum(positives, negatives) ⇒ Buffer

Computes the sum of multiple positive and negative pedersen commitments.

Kind: instance method of Secp

ParamTypeDefault
positivesArray.<Buffer>[]
negativesArray.<Buffer>[]

secp.verifyCommitSum(positives, negatives) ⇒ boolean

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

ParamTypeDefault
positivesArray.<Buffer>[]
negativesArray.<Buffer>[]

secp.blindSum(positives, negatives) ⇒ Buffer

Computes the sum of multiple positive and negative blinding factors.

Kind: instance method of Secp

ParamTypeDefault
positivesArray.<Buffer>[]
negativesArray.<Buffer>[]

secp.commitmentToPubKey(commitment) ⇒ Buffer

Retrieves pubKey from commit.

Kind: instance method of Secp

ParamType
commitmentBuffer

secp.commitmentSerialize(commitment) ⇒ Buffer

Serializes commitment.

Kind: instance method of Secp

ParamType
commitmentBuffer

secp.commitmentParse(buffer) ⇒ Buffer

Parses a commitment.

Kind: instance method of Secp

ParamType
bufferBuffer

secp.verifyFromCommit(msg, sig, commitment) ⇒ boolean

Verify commitment.

Kind: instance method of Secp

ParamType
msgBuffer
sigBuffer
commitmentBuffer

secp.bulletProofVerify(commitment, rangeProof, extraData) ⇒ boolean

Verify with bullet proof that a committed value is positive.

Kind: instance method of Secp

ParamType
commitmentBuffer
rangeProofBuffer
extraDataBuffer

secp.bulletProofVerifyMulti(commitments, rangeProofs, extraData) ⇒ boolean

Verify with bullet proof that a committed value is positive.

Kind: instance method of Secp

ParamType
commitmentsBuffer
rangeProofsArray.<Buffer>
extraDataBuffer

secp.bulletProofCreate(amount, secretKey, nonce, extraData, msg) ⇒ Buffer

Create a bulletproof. The blinding factor for commitment should be secretKey.

Kind: instance method of Secp

ParamTypeDefault
amountnumber
secretKeyBuffer
nonceBuffer
extraDataBuffer
msgBufferBuffer.alloc(16, 0)

secp.bulletProofRewind(commitment, nonce, extraData, rangeProof) ⇒ Buffer

Rewind a rangeProof to retrieve the amount

Kind: instance method of Secp

ParamType
commitmentnumber
noncenumber
extraDatanumber
rangeProofnumber

secp.aggsigCreateSecnonce() ⇒ Buffer

Creates a new secure nonce (as a SecretKey), guaranteed to be usable during aggsig creation.

Kind: instance method of Secp

secp.aggsigSignSingle(msg, secretKey, pubKeySum) ⇒ Buffer

Simple signature (nonce will be created).

Kind: instance method of Secp

ParamType
msgBuffer
secretKeyBuffer
pubKeySumBuffer

secp.aggsigSignFromSecretKey(secretKey, msg, blindSum) ⇒ Buffer

Calculates a signature for msg given the secretKey and an optional blindSum

Kind: instance method of Secp

ParamType
secretKeyBuffer
msgBuffer
blindSumBuffer

secp.aggsigCalculatePartialSig(secretKey, secNonce, nonceSum, pubKeySum, msg) ⇒ Buffer

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

ParamTypeDescription
secretKeyBufferThe signer's secret key
secNonceBufferThe signer's secret nonce (the public version of which was added to the nonceSum total)
nonceSumBufferThe sum of the public nonces of all signers participating in the full signature. This value is encoded in e.
pubKeySumBuffer(Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e.
msgBufferThe message to sign.

secp.aggsigVerifySingle(sig, msg, pubNonce, pubKey, pubKeyTotal, extraPubKey, isPartial) ⇒ Buffer

Single-Signer (plain old Schnorr, sans-multisig) signature verification

Kind: instance method of Secp Returns: Buffer - - Signature on success

ParamTypeDescription
sigBufferThe signature
msgBufferthe message to verify
pubNonceBufferif not null overrides the public nonce used to calculate e
pubKeyBufferthe public key
pubKeyTotalBufferThe total of all public keys (for the message in e)
extraPubKeyBufferif not null, subtract this pubKey from sG
isPartialbooleanwhether this is a partial sig, or a fully-combined sig

secp.aggsigVerifyPartialSig(sig, pubNonceSum, pubKey, pubKeySum, msg) ⇒ Buffer

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

ParamTypeDescription
sigBufferThe signature to validate, created via a call to calculate_partial_sig
pubNonceSumBufferThe sum of the public nonces of all signers participating in the full signature. This value is encoded in e.
pubKeyBufferCorresponding Public Key of the private key used to sign the message.
pubKeySumBuffer(Optional) The sum of the public keys of all signers participating in the full signature. If included, this value is encoded in e.
msgBufferThe message to verify.

secp.aggsigVerifySingleFromCommit(sig, msg, commit) ⇒ Buffer

Simple verification a single signature from a commitment. The public key used to verify the signature is derived from the commit.

Kind: instance method of Secp

ParamTypeDescription
sigBufferThe Signature to verify
msgBufferThe message to sign.
commitBufferThe commitment to verify. The actual public key used during verification is derived from this commit.

secp.aggsigVerifyCompletedSig(sig, pubKey, pubKeySum, msg) ⇒ Buffer

Verifies a completed (summed) signature, which must include the message and pubKey sum values that are used during signature creation time to create 'e'

Kind: instance method of Secp

ParamTypeDescription
sigBufferThe Signature to verify
pubKeyBufferCorresponding Public Key of the private key used to sign the message.
pubKeySumBuffer(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.
msgBufferThe message to verify.

secp.aggsigAddSignatures(partSigs, nonceSum) ⇒ Buffer

Adds signatures

Kind: instance method of Secp

ParamType
partSigsBuffer
nonceSumBuffer

ZERO_8 : Buffer

Kind: global constant

ZERO_32 : Buffer

Kind: global constant

ZERO_64 : Buffer

Kind: global constant

sha256(v) ⇒ PromiseLike.<ArrayBuffer>

create random sha256 Buffer

Kind: global function

ParamType
vstring

uInt64T(num) ⇒ Buffer

Takes any number (native number, BN, or string) and converts it to uInt64T (64-bit BE Buffer) suitable for use by the C++ bindings.

Kind: global function

ParamTypeDescription
numnumbernumber to convert.
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago