Module: crypto/ec

Members

(private, static, constant) binding :Boolean

Whether we're using native bindings.

Type:
  • Boolean
Source:

Methods

(static) ecdh(pub, priv) → {Buffer}

Create an ecdh.

Parameters:
Name Type Description
pub Buffer
priv Buffer
Source:
Returns:
Type
Buffer

(static) fromDER(sig) → {Buffer}

Convert DER signature to R/S.

Parameters:
Name Type Description
sig Buffer
Source:
Returns:

R/S-formatted signature.

Type
Buffer

(static) generatePrivateKey() → {Buffer}

Generate a private key.

Source:
Returns:

Private key.

Type
Buffer

(static) isLowS(sig) → {Boolean}

Test whether a signature has a low S value.

Parameters:
Name Type Description
sig Buffer
Source:
Returns:
Type
Boolean

(static) privateKeyTweakAdd(privateKey, tweak) → {Buffer}

((tweak + key) % n)

Parameters:
Name Type Description
privateKey Buffer
tweak Buffer
Source:
Returns:

privateKey

Type
Buffer

(static) privateKeyVerify(key) → {Boolean}

Validate a private key.

Parameters:
Name Type Description
key Buffer
Source:
Returns:

True if buffer is a valid private key.

Type
Boolean

(static) publicKeyConvert(pub) → {Buffer}

Compress or decompress public key.

Parameters:
Name Type Description
pub Buffer
Source:
Returns:
Type
Buffer

(static) publicKeyCreate(priv, compressednullable) → {Buffer}

Create a public key from a private key.

Parameters:
Name Type Attributes Description
priv Buffer
compressed Boolean <nullable>
Source:
Returns:
Type
Buffer

(static) publicKeyTweakAdd(publicKey, tweak) → {Buffer}

((g * tweak) + key)

Parameters:
Name Type Description
publicKey Buffer
tweak Buffer
Source:
Returns:

publicKey

Type
Buffer

(static) publicKeyVerify(key) → {Boolean}

Validate a public key.

Parameters:
Name Type Description
key Buffer
Source:
Returns:

True if buffer is a valid public key.

Type
Boolean

(static) recover(msg, sig, jnullable, compressednullable) → {Array:.<Buffer:>|Buffer|null}

Recover a public key.

Parameters:
Name Type Attributes Description
msg Buffer
sig Buffer
j Number <nullable>
compressed Boolean <nullable>
Source:
Returns:
Type
Array:.<Buffer:> | Buffer | null

(static) sign(msg, key) → {Buffer}

Sign a message.

Parameters:
Name Type Description
msg Buffer
key Buffer

Private key.

Source:
Returns:

DER-formatted signature.

Type
Buffer

(static) toDER(sig) → {Buffer}

Convert R/S signature to DER.

Parameters:
Name Type Description
sig Buffer
Source:
Returns:

DER-formatted signature.

Type
Buffer

(static) verify(msg, sig, key, historicalnullable, highnullable) → {Boolean}

Verify a signature.

Parameters:
Name Type Attributes Description
msg Buffer
sig Buffer

DER formatted.

key Buffer
historical Boolean <nullable>

Whether this should be treated as a "historical" signature. This allows signatures to be of odd lengths.

high Boolean <nullable>

Allow high S value.

Source:
Returns:
Type
Boolean