An Ed25519Signer that is initialized with an Ed25519 key pair and can be used with Builders to sign Farcaster Messages.
Name
Type
Description
scheme
Uint8Array
Signature scheme used when signing messages
static
new NobleEd25519Signer
import { NobleEd25519Signer } from '@farcaster/hub-nodejs' ;
import * as ed from '@noble/ed25519' ;
const privateKeyBytes = ed . utils . randomPrivateKey ( ) ;
const signer = new NobleEd25519Signer ( privateKeyBytes ) ;
Value
Description
NobleEd25519Signer
An NobleEd25519Signer instance
Name
Type
Description
privateKey
Uint8Array
Bytes of the Signers private key
Returns the 256-bit public key in bytes.
const signerKeyResult = await signer . getSignerKey ( ) ;
if ( signerKeyResult . isOk ( ) ) {
console . log ( signerKeyResult . value ) ;
}
Value
Description
HubAsyncResult<Uint8Array>
The 256-bit address as a Uint8Array.
Generates a 256-bit signature of a message hash using the EdDSA key pair.
import { createHash , randomBytes } from 'crypto' ;
const messageBytes = randomBytes ( 32 ) ;
const messageHash = createHash ( 'sha256' ) . update ( messageBytes ) . digest ( ) ;
const signatureResult = await signer . signMessageHash ( messageHash ) ;
if ( signatureResult . isOk ( ) ) {
console . log ( signatureResult . value ) ;
}
Value
Description
HubAsyncResult<Uint8Array>
The 256-bit signature as a Uint8Array.
Name
Type
Description
hash
Uint8Array
The 256-bit hash of the message to be signed.