PrivateKey
A signing key. You can generate one via PrivateKey.random.
Extends
CircuitValue
Constructors
new PrivateKey(s)
new PrivateKey(s: Scalar): PrivateKey
Parameters
• s: Scalar
Returns
Overrides
CircuitValue.constructor
Source
lib/provable/crypto/signature.ts:25
Properties
s
s: Scalar;
Source
lib/provable/crypto/signature.ts:23
Methods
assertEquals()
assertEquals(x: this): void
Parameters
• x: this
Returns
void
Inherited from
CircuitValue.assertEquals
Source
lib/provable/types/circuit-value.ts:130
equals()
equals(x: this): Bool
Parameters
• x: this
Returns
Inherited from
CircuitValue.equals
Source
lib/provable/types/circuit-value.ts:126
isConstant()
isConstant(): boolean
Returns
boolean
Inherited from
CircuitValue.isConstant
Source
lib/provable/types/circuit-value.ts:134
toBase58()
toBase58(): string
Encodes a PrivateKey into a base58 string.
Returns
string
a base58 encoded string
Source
lib/provable/crypto/signature.ts:105
toBigInt()
toBigInt(): bigint
Convert this PrivateKey to a bigint
Returns
bigint
Source
lib/provable/crypto/signature.ts:68
toConstant()
toConstant(): this
Returns
this
Inherited from
CircuitValue.toConstant
Source
lib/provable/types/circuit-value.ts:122
toFields()
toFields(): Field[]
Returns
Field
[]
Inherited from
CircuitValue.toFields
Source
lib/provable/types/circuit-value.ts:85
toJSON()
toJSON(): any
Returns
any
Inherited from
CircuitValue.toJSON
Source
lib/provable/types/circuit-value.ts:118
toPublicKey()
toPublicKey(): PublicKey
Derives the associated public key.
Returns
a PublicKey.
Source
lib/provable/crypto/signature.ts:87
check()
static check<T>(this: T, v: InstanceType<T>): void
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
void
Inherited from
CircuitValue.check
Source
lib/provable/types/circuit-value.ts:163
empty()
static empty<T>(): InstanceType<T>
Type parameters
• T extends AnyConstructor
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.empty
Source
lib/provable/types/circuit-value.ts:218
fromBase58()
static fromBase58(privateKeyBase58: string): PrivateKey
Decodes a base58 string into a PrivateKey.
Parameters
• privateKeyBase58: string
Returns
a PrivateKey.
Source
lib/provable/crypto/signature.ts:96
fromBigInt()
static fromBigInt(sk: bigint): PrivateKey
Create a PrivateKey from a bigint
Warning: Private keys should be sampled from secure randomness with sufficient entropy. Be careful that you don't use this method to create private keys that were sampled insecurely.
Parameters
• sk: bigint
Returns
Source
lib/provable/crypto/signature.ts:78
fromBits()
static fromBits(bs: Bool[]): PrivateKey
Deserializes a list of bits into a PrivateKey.
Parameters
• bs: Bool
[]
a list of Bool.
Returns
a PrivateKey.
Source
lib/provable/crypto/signature.ts:61
fromFields()
static fromFields<T>(this: T, xs: Field[]): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• xs: Field
[]
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromFields
Source
lib/provable/types/circuit-value.ts:138
fromJSON()
static fromJSON<T>(this: T, value: any): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• value: any
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromJSON
Source
lib/provable/types/circuit-value.ts:196
fromObject()
static fromObject<T>(this: T, value: NonMethods<InstanceType<T>>): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• value: NonMethods
\<InstanceType
\<T
>>
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.fromObject
Source
lib/provable/types/circuit-value.ts:30
fromValue()
static fromValue<T>(this: T, v: bigint | PrivateKey): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: bigint
| PrivateKey
Returns
InstanceType
\<T
>
Overrides
CircuitValue.fromValue
Source
lib/provable/crypto/signature.ts:121
random()
static random(): PrivateKey
Generate a random private key.
You can obtain the associated public key via toPublicKey. And generate signatures via Signature.create.
Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, and can be safely used to generate a real private key.
Returns
a new PrivateKey.
Source
lib/provable/crypto/signature.ts:40
randomKeypair()
static randomKeypair(): {
privateKey: PrivateKey;
publicKey: PublicKey;
}
Create a random keypair { privateKey: PrivateKey, publicKey: PublicKey }
.
Note: This uses node or browser built-in APIs to obtain cryptographically strong randomness, and can be safely used to generate a real keypair.
Returns
{
privateKey: PrivateKey;
publicKey: PublicKey;
}
privateKey
privateKey: PrivateKey;
publicKey
publicKey: PublicKey;
Source
lib/provable/crypto/signature.ts:50
sizeInFields()
static sizeInFields(): number
Returns
number
Inherited from
CircuitValue.sizeInFields
Source
lib/provable/types/circuit-value.ts:37
toAuxiliary()
static toAuxiliary(): []
Returns
[]
Inherited from
CircuitValue.toAuxiliary
Source
lib/provable/types/circuit-value.ts:59
toBase58()
static toBase58(privateKey: {
s: Scalar;
}): string
Static method to encode a PrivateKey into a base58 string.
Parameters
• privateKey
• privateKey.s: Scalar
Returns
string
a base58 encoded string
Source
lib/provable/crypto/signature.ts:114
toConstant()
static toConstant<T>(this: T, t: InstanceType<T>): InstanceType<T>
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• t: InstanceType
\<T
>
Returns
InstanceType
\<T
>
Inherited from
CircuitValue.toConstant
Source
lib/provable/types/circuit-value.ts:177
toFields()
static toFields<T>(this: T, v: InstanceType<T>): Field[]
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
Field
[]
Inherited from
CircuitValue.toFields
Source
lib/provable/types/circuit-value.ts:42
toInput()
static toInput<T>(this: T, v: InstanceType<T>): HashInput
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
HashInput
Inherited from
CircuitValue.toInput
Source
lib/provable/types/circuit-value.ts:63
toJSON()
static toJSON<T>(this: T, v: InstanceType<T>): any
Type parameters
• T extends AnyConstructor
Parameters
• this: T
• v: InstanceType
\<T
>
Returns
any
Inherited from
CircuitValue.toJSON
Source
lib/provable/types/circuit-value.ts:185
toValue()
static toValue(v: PrivateKey): bigint
Parameters
• v: PrivateKey
Returns
bigint
Overrides
CircuitValue.toValue