Signature
Utility functions for working with ECDSA signatures.
Examples
Below are some examples demonstrating common usages of the Signature
module:
Serializing a Signature
Signatures can be serialized to Hex or Bytes using Signature.toHex
:
import { Signature } from 'ox'
const signature = Signature.toHex({
r: 49782753348462494199823712700004552394425719014458918871452329774910450607807n,
s: 33726695977844476214676913201140481102225469284307016937915595756355928419768n,
yParity: 1
})
'0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c'
Deserializing a Signature
Signatures can be deserialized from Hex or Bytes using Signature.fromHex
:
import { Signature } from 'ox'
Signature.fromHex('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')
{ r: 5231...n, s: 3522...n, yParity: 0 }
Functions
Errors
Name | Description |
---|---|
Signature.InvalidRError | Thrown when the signature has an invalid r value. |
Signature.InvalidSerializedSizeError | Thrown when the serialized signature is of an invalid size. |
Signature.InvalidSError | Thrown when the signature has an invalid s value. |
Signature.InvalidVError | Thrown when the signature has an invalid v value. |
Signature.InvalidYParityError | Thrown when the signature has an invalid yParity value. |
Signature.MissingPropertiesError | Thrown when the signature is missing either an r , s , or yParity property. |
Types
Name | Description |
---|---|
Signature.Legacy | (Legacy) ECDSA signature. |
Signature.LegacyRpc | RPC-formatted (Legacy) ECDSA signature. |
Signature.Rpc | RPC-formatted ECDSA signature. |
Signature.Signature | Root type for an ECDSA signature. |
Signature.Tuple |