PrivateKey
Defined in: lib/provable/crypto/signature.ts:22
A signing key. You can generate one via PrivateKey.random.
Extends
CircuitValue
Constructors
new PrivateKey()
new PrivateKey(s: Scalar): PrivateKey
Defined in: lib/provable/crypto/signature.ts:25
Parameters
s
Returns
Overrides
CircuitValue.constructor
Properties
s
s: Scalar;
Defined in: lib/provable/crypto/signature.ts:23
Methods
assertEquals()
assertEquals(x: this): void
Defined in: lib/provable/types/circuit-value.ts:121
Parameters
x
this
Returns
void
Inherited from
CircuitValue.assertEquals
equals()
equals(x: this): Bool
Defined in: lib/provable/types/circuit-value.ts:117
Parameters
x
this
Returns
Inherited from
CircuitValue.equals
isConstant()
isConstant(): boolean
Defined in: lib/provable/types/circuit-value.ts:125
Returns
boolean
Inherited from
CircuitValue.isConstant
toBase58()
toBase58(): string
Defined in: lib/provable/crypto/signature.ts:105
Encodes a PrivateKey into a base58 string.
Returns
string
a base58 encoded string
toBigInt()
toBigInt(): bigint
Defined in: lib/provable/crypto/signature.ts:68
Convert this PrivateKey to a bigint
Returns
bigint
toConstant()
toConstant(): this
Defined in: lib/provable/types/circuit-value.ts:113
Returns
this
Inherited from
CircuitValue.toConstant
toFields()
toFields(): Field[]
Defined in: lib/provable/types/circuit-value.ts:79
Returns
Field
[]
Inherited from
CircuitValue.toFields
toJSON()
toJSON(): any
Defined in: lib/provable/types/circuit-value.ts:109
Returns
any
Inherited from
CircuitValue.toJSON
toPublicKey()
toPublicKey(): PublicKey
Defined in: lib/provable/crypto/signature.ts:87
Derives the associated public key.
Returns
a PublicKey.
check()
static check<T>(this: T, v: InstanceType<T>): void
Defined in: lib/provable/types/circuit-value.ts:148
Type Parameters
• T extends AnyConstructor
Parameters
this
T
v
InstanceType
<T
>
Returns
void
Inherited from
CircuitValue.check
empty()
static empty<T>(): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:205
Type Parameters
• T extends AnyConstructor
Returns
InstanceType
<T
>
Inherited from
CircuitValue.empty
fromBase58()
static fromBase58(privateKeyBase58: string): PrivateKey
Defined in: lib/provable/crypto/signature.ts:96
Decodes a base58 string into a PrivateKey.
Parameters
privateKeyBase58
string
Returns
a PrivateKey.
fromBigInt()
static fromBigInt(sk: bigint): PrivateKey
Defined in: lib/provable/crypto/signature.ts:78
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
fromBits()
static fromBits(bs: Bool[]): PrivateKey
Defined in: lib/provable/crypto/signature.ts:61
Deserializes a list of bits into a PrivateKey.
Parameters
bs
Bool
[]
a list of Bool.
Returns
a PrivateKey.
fromFields()
static fromFields<T>(this: T, xs: Field[]): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:129
Type Parameters
• T extends AnyConstructor
Parameters
this
T
xs
Field
[]
Returns
InstanceType
<T
>
Inherited from
CircuitValue.fromFields
fromJSON()
static fromJSON<T>(this: T, value: any): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:186
Type Parameters
• T extends AnyConstructor
Parameters
this
T
value
any
Returns
InstanceType
<T
>
Inherited from
CircuitValue.fromJSON
fromObject()
static fromObject<T>(this: T, value: NonMethods<InstanceType<T>>): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:30
Type Parameters
• T extends AnyConstructor
Parameters
this
T
value
NonMethods
<InstanceType
<T
>>
Returns
InstanceType
<T
>
Inherited from
CircuitValue.fromObject
fromValue()
static fromValue<T>(this: T, v: bigint | PrivateKey): InstanceType<T>
Defined in: lib/provable/crypto/signature.ts:121
Type Parameters
• T extends AnyConstructor
Parameters
this
T
v
bigint
| PrivateKey
Returns
InstanceType
<T
>
Overrides
CircuitValue.fromValue
random()
static random(): PrivateKey
Defined in: lib/provable/crypto/signature.ts:40
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.
randomKeypair()
static randomKeypair(): {
privateKey: PrivateKey;
publicKey: PublicKey;
}
Defined in: lib/provable/crypto/signature.ts:50
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;
sizeInFields()
static sizeInFields(): number
Defined in: lib/provable/types/circuit-value.ts:37
Returns
number
Inherited from
CircuitValue.sizeInFields
toAuxiliary()
static toAuxiliary(): []
Defined in: lib/provable/types/circuit-value.ts:56
Returns
[]
Inherited from
CircuitValue.toAuxiliary
toBase58()
static toBase58(privateKey: {
s: Scalar;
}): string
Defined in: lib/provable/crypto/signature.ts:114
Static method to encode a PrivateKey into a base58 string.
Parameters
privateKey
s
Returns
string
a base58 encoded string
toCanonical()
static toCanonical<T>(this: T, value: InstanceType<T>): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:161
Type Parameters
• T extends AnyConstructor
Parameters
this
T
value
InstanceType
<T
>
Returns
InstanceType
<T
>
Inherited from
CircuitValue.toCanonical
toConstant()
static toConstant<T>(this: T, t: InstanceType<T>): InstanceType<T>
Defined in: lib/provable/types/circuit-value.ts:170
Type Parameters
• T extends AnyConstructor
Parameters
this
T
t
InstanceType
<T
>
Returns
InstanceType
<T
>
Inherited from
CircuitValue.toConstant
toFields()
static toFields<T>(this: T, v: InstanceType<T>): Field[]
Defined in: lib/provable/types/circuit-value.ts:42
Type Parameters
• T extends AnyConstructor
Parameters
this
T
v
InstanceType
<T
>
Returns
Field
[]
Inherited from
CircuitValue.toFields
toInput()
static toInput<T>(this: T, v: InstanceType<T>): HashInput
Defined in: lib/provable/types/circuit-value.ts:60
Type Parameters
• T extends AnyConstructor
Parameters
this
T
v
InstanceType
<T
>
Returns
HashInput
Inherited from
CircuitValue.toInput
toJSON()
static toJSON<T>(this: T, v: InstanceType<T>): any
Defined in: lib/provable/types/circuit-value.ts:175
Type Parameters
• T extends AnyConstructor
Parameters
this
T
v
InstanceType
<T
>
Returns
any
Inherited from
CircuitValue.toJSON
toValue()
static toValue(v: PrivateKey): bigint
Defined in: lib/provable/crypto/signature.ts:118
Parameters
v
Returns
bigint
Overrides
CircuitValue.toValue