PrivateKey
Class: PrivateKey
A signing key. You can generate one via random.
Hierarchy
↳
PrivateKey
Table of contents
Constructors
Properties
Methods
- assertEquals
- equals
- isConstant
- toBase58
- toBigInt
- toConstant
- toFields
- toJSON
- toPublicKey
- check
- empty
- fromBase58
- fromBigInt
- fromBits
- fromFields
- fromJSON
- fromObject
- random
- randomKeypair
- sizeInFields
- toAuxiliary
- toBase58
- toConstant
- toFields
- toInput
- toJSON
Constructors
constructor
• new PrivateKey(s
)
Parameters
Name | Type |
---|---|
s | Scalar |
Overrides
Defined in
Properties
s
• s: Scalar
Defined in
Methods
assertEquals
▸ assertEquals(x
): void
Parameters
Name | Type |
---|---|
x | PrivateKey |
Returns
void
Inherited from
Defined in
equals
▸ equals(x
): Bool
Parameters
Name | Type |
---|---|
x | PrivateKey |
Returns
Inherited from
Defined in
isConstant
▸ isConstant(): boolean
Returns
boolean
Inherited from
Defined in
toBase58
▸ toBase58(): string
Encodes a PrivateKey into a base58 string.
Returns
string
a base58 encoded string
Defined in
toBigInt
▸ toBigInt(): bigint
Convert this PrivateKey to a bigint
Returns
bigint
Defined in
toConstant
▸ toConstant(): PrivateKey
Returns
Inherited from
Defined in
toFields
▸ toFields(): Field
[]
Returns
Field
[]
Inherited from
Defined in
toJSON
▸ toJSON(): any
Returns
any
Inherited from
Defined in
toPublicKey
▸ toPublicKey(): PublicKey
Derives the associated public key.
Returns
a PublicKey.
Defined in
check
▸ Static
check\<T
>(this
, v
): void
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
v | InstanceType \<T > |
Returns
void
Inherited from
Defined in
empty
▸ Static
empty\<T
>(): InstanceType
\<T
>
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Returns
InstanceType
\<T
>
Inherited from
Defined in
fromBase58
▸ Static
fromBase58(privateKeyBase58
): PrivateKey
Decodes a base58 string into a PrivateKey.
Parameters
Name | Type |
---|---|
privateKeyBase58 | string |
Returns
a PrivateKey.
Defined in
fromBigInt
▸ Static
fromBigInt(sk
): 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
Name | Type |
---|---|
sk | bigint |
Returns
Defined in
fromBits
▸ Static
fromBits(bs
): PrivateKey
Deserializes a list of bits into a PrivateKey.
Parameters
Name | Type | Description |
---|---|---|
bs | Bool [] | a list of Bool. |
Returns
a PrivateKey.
Defined in
fromFields
▸ Static
fromFields\<T
>(this
, xs
): InstanceType
\<T
>
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
xs | Field [] |
Returns
InstanceType
\<T
>
Inherited from
Defined in
fromJSON
▸ Static
fromJSON\<T
>(this
, value
): InstanceType
\<T
>
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
value | any |
Returns
InstanceType
\<T
>
Inherited from
Defined in
fromObject
▸ Static
fromObject\<T
>(this
, value
): InstanceType
\<T
>
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
value | NonMethods \<InstanceType \<T >> |
Returns
InstanceType
\<T
>
Inherited from
Defined in
random
▸ Static
random(): PrivateKey
Generate a random private key.
You can obtain the associated public key via toPublicKey. And generate signatures via 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.
Defined in
randomKeypair
▸ Static
randomKeypair(): Object
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
Object
Name | Type |
---|---|
privateKey | PrivateKey |
publicKey | PublicKey |
Defined in
sizeInFields
▸ Static
sizeInFields(): number
Returns
number
Inherited from
Defined in
toAuxiliary
▸ Static
toAuxiliary(): []
Returns
[]
Inherited from
Defined in
toBase58
▸ Static
toBase58(privateKey
): string
Static method to encode a PrivateKey into a base58 string.
Parameters
Name | Type |
---|---|
privateKey | Object |
privateKey.s | Scalar |
Returns
string
a base58 encoded string
Defined in
toConstant
▸ Static
toConstant\<T
>(this
, t
): InstanceType
\<T
>
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
t | InstanceType \<T > |
Returns
InstanceType
\<T
>
Inherited from
Defined in
toFields
▸ Static
toFields\<T
>(this
, v
): Field
[]
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
v | InstanceType \<T > |
Returns
Field
[]
Inherited from
Defined in
toInput
▸ Static
toInput\<T
>(this
, v
): HashInput
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
v | InstanceType \<T > |
Returns
HashInput
Inherited from
Defined in
toJSON
▸ Static
toJSON\<T
>(this
, v
): any
Type parameters
Name | Type |
---|---|
T | extends AnyConstructor |
Parameters
Name | Type |
---|---|
this | T |
v | InstanceType \<T > |
Returns
any