Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:102
An Identity that can sign blobs.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”
protected
new Secp256k1KeyIdentity(publicKey
,_privateKey
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:223
Parameters
Section titled “Parameters”publicKey
Section titled “publicKey”_privateKey
Section titled “_privateKey”Uint8Array
Returns
Section titled “Returns”Secp256k1KeyIdentity
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_principal
Section titled “_principal”
protected
_principal:undefined
|Principal
Defined in: agent/lib/esm/auth.d.ts:52
Inherited from
Section titled “Inherited from”_privateKey
Section titled “_privateKey”
protected
_privateKey:Uint8Array
Defined in: identity-secp256k1/src/secp256k1.ts:225
_publicKey
Section titled “_publicKey”_publicKey:
Secp256k1PublicKey
Defined in: identity-secp256k1/src/secp256k1.ts:221
Methods
Section titled “Methods”getKeyPair()
Section titled “getKeyPair()”getKeyPair():
KeyPair
Defined in: identity-secp256k1/src/secp256k1.ts:243
Return a copy of the key pair.
Returns
Section titled “Returns”KeyPair
getPrincipal()
Section titled “getPrincipal()”getPrincipal():
Principal
Defined in: agent/lib/esm/auth.d.ts:65
Get the principal represented by this identity. Normally should be a
Principal.selfAuthenticating()
.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getPublicKey()
Section titled “getPublicKey()”getPublicKey():
Required
<PublicKey
>
Defined in: identity-secp256k1/src/secp256k1.ts:254
Return the public key.
Returns
Section titled “Returns”Required
<PublicKey
>
Required
Overrides
Section titled “Overrides”sign()
Section titled “sign()”sign(
data
):Promise
<Signature
>
Defined in: identity-secp256k1/src/secp256k1.ts:263
Signs a blob of data, with this identity’s private key.
Parameters
Section titled “Parameters”Uint8Array
bytes to hash and sign with this identity’s secretKey, producing a signature
Returns
Section titled “Returns”Promise
<Signature
>
signature
Overrides
Section titled “Overrides”toJSON()
Section titled “toJSON()”toJSON():
JsonableSecp256k1Identity
Defined in: identity-secp256k1/src/secp256k1.ts:235
Serialize this key to JSON-serializable object.
Returns
Section titled “Returns”JsonableSecp256k1Identity
transformRequest()
Section titled “transformRequest()”transformRequest(
request
):Promise
<unknown
>
Defined in: agent/lib/esm/auth.d.ts:72
Transform a request into a signed version of the request. This is done last after the transforms on the body of a request. The returned object can be anything, but must be serializable to CBOR.
Parameters
Section titled “Parameters”request
Section titled “request”internet computer request to transform
Returns
Section titled “Returns”Promise
<unknown
>
Inherited from
Section titled “Inherited from”fromJSON()
Section titled “fromJSON()”
static
fromJSON(json
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:145
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Secp256k1KeyIdentity
fromKeyPair()
Section titled “fromKeyPair()”
static
fromKeyPair(publicKey
,privateKey
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:162
generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user’s private key
Parameters
Section titled “Parameters”publicKey
Section titled “publicKey”Uint8Array
Uint8Array
privateKey
Section titled “privateKey”Uint8Array
Uint8Array
Returns
Section titled “Returns”Secp256k1KeyIdentity
Secp256k1KeyIdentity
fromParsedJson()
Section titled “fromParsedJson()”
static
fromParsedJson(obj
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:137
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Secp256k1KeyIdentity
fromPem()
Section titled “fromPem()”
static
fromPem(pemKey
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:216
Utility method to create a Secp256k1KeyIdentity from a PEM-encoded key.
Parameters
Section titled “Parameters”pemKey
Section titled “pemKey”string
PEM-encoded key as a string
Returns
Section titled “Returns”Secp256k1KeyIdentity
- Secp256k1KeyIdentity
fromSecretKey()
Section titled “fromSecretKey()”
static
fromSecretKey(secretKey
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:171
generates an identity from an existing secret key, and is the correct method to generate an identity from a seed phrase. Please ensure you protect the user’s private key.
Parameters
Section titled “Parameters”secretKey
Section titled “secretKey”Uint8Array
Uint8Array
Returns
Section titled “Returns”Secp256k1KeyIdentity
- Secp256k1KeyIdentity
fromSeedPhrase()
Section titled “fromSeedPhrase()”
static
fromSeedPhrase(seedPhrase
,password?
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:183
Generates an identity from a seed phrase. Use carefully - seed phrases should only be used in secure contexts, and you should avoid having users copying and pasting seed phrases as much as possible.
Parameters
Section titled “Parameters”seedPhrase
Section titled “seedPhrase”either an array of words or a string of words separated by spaces.
string
| string
[]
password?
Section titled “password?”string
optional password to be used by bip39
Returns
Section titled “Returns”Secp256k1KeyIdentity
Secp256k1KeyIdentity
generate()
Section titled “generate()”
static
generate(seed?
):Secp256k1KeyIdentity
Defined in: identity-secp256k1/src/secp256k1.ts:111
Generates an identity. If a seed is provided, the keys are generated from the seed according to BIP 0032. Otherwise, the key pair is randomly generated. This method throws an error in case the seed is not 32 bytes long or invalid for use as a private key.
Parameters
Section titled “Parameters”Uint8Array
<ArrayBufferLike
>
the optional seed
Returns
Section titled “Returns”Secp256k1KeyIdentity
Secp256k1KeyIdentity