Skip to main content

ETH Sign

The EthSignature class represents an Ethereum signature.

Used to parse the signed result returned by the device.

Inputs

FieldValue TypeMeaning
signatureBufferThe signature data (65 bytes: r + s + v)
requestIdBufferThe request ID (optional)
originstringThe origin information (optional)

UR Demo

UR:ETH-SIGNATURE/OTADTPDAGDSWNNYAHGTOKPFPIAPANNROLNSAVYDTHHAOHDFPCATKCPPFYLENGAGLMKMUCAYKFPFSDREOMENTPKBGEONDCHFDNBKOSSTPDWETSGBZDNCMCHKPNYDMKIDPTDRYJSDRTKCTIOFPQZHFLNSKVACLMNIYTKLGISFRWLKTZTREAEAXIYGWJTIHGRIHKKPLGDEEDS

Decode Demo

import { URDecoder } from "@ngraveio/bc-ur";
import { EthSignature } from "@keystonehq/bc-ur-registry-eth";

const dec = new URDecoder();
// Feed each scanned frame string into the decoder
// feed each scanned frame into dec.receivePart(frame)

if (dec.isComplete()) {
const ur = dec.resultUR(); // the decoded UR should be of type 'eth-signature'
const signatureData = EthSignature.fromCBOR(ur.cbor);

const requestId = signatureData.getRequestId();
const signature = signatureData.getSignature();

// Extract the r, s, and v components
const r = signature.slice(0, 32);
const s = signature.slice(32, 64);
const v = signature.slice(64, 65);

// Attach it to the transaction and broadcast
}

Signature Format

The signature is 65 bytes:

  • r (32 bytes): First part of ECDSA signature
  • s (32 bytes): Second part of ECDSA signature
  • v (1 byte): Recovery ID