Skip to main content

BIP32 Support

We support generating signatures for a BIP32 child key. Perform keygen once, and generate signatures for all BIP32 child keys!

Perform Derive Child Public-Key


  • Call SilentShard.ECDSA.deriveChildPublicKeyAsData or SilentShard.EdDSA.deriveChildPublicKeyAsData which returns Result of Success with Child Public-Key bytes as Data or Failure with error.
  • You can get public key as various string formats :
    • Hex String - By using
      SilentShardDuo.ECDSA.deriveChildPublicKeyAsHex()
      //or
      SilentShardDuo.EdDSA.deriveChildPublicKeyAsHex()
    • Base64 String - By using
      SilentShardDuo.ECDSA.deriveChildPublicKeyAsBase64()
      //or
      SilentShardDuo.EdDSA.deriveChildPublicKeyAsBase64()
    • UrlSafeBase64 String -
      SilentShardDuo.ECDSA.deriveChildPublicKeyAsUrlSafeBase64()
      //or
      SilentShardDuo.EdDSA.deriveChildPublicKeyAsUrlSafeBase64()
      Result of Success with Child Public-Key as String in desired format or Failure with error

Example


Example.swift

let MESSAGE_HASH = "cfa1ff5424d14eb60614d7ddf65a32243d26ddf7000d10007853d7336395efe4"

func deriveChildPublicKeyUsingKeyshare(
keyshare: Data, duoSession: DuoSession
) async -> Data? {

// performing signature example for context
let result = await duoSession.signature(
keyshare: keyshare, message: MESSAGE_HASH,
chainPath: "m" // This is the default, use your desired path here. For e.g 'm/1/2'
)
// returns nil if operation fails or other flow you might have
switch result {
case .success(let dataBytes):
do {
// do something with bytes, Here, let's derive child public key in various formats
// Assuming it as ECDSA

// hex string
let childPublicKeyAsHex = await SilentShardDuo.ECDSA
.deriveChildPublicKeyAsHex(
keyshare,
derivationPath: "m/1"
)

// bytes
let childPublicKeyAsData = await SilentShardDuo.ECDSA
.deriveChildPublicKeyAsData(
keyshare,
derivationPath: "m/1"
)

// base64 string
let childPublicKeyAsDataAsBase64String =
await SilentShardDuo.ECDSA.deriveChildPublicKeyAsBase64(
keyshare,
derivationPath: "m/1"
)

// url safe base64 string
let childPublicKeyAsDataAsUrlSafeBase64String =
await SilentShardDuo.ECDSA
.deriveChildPublicKeyAsUrlSafeBase64(
keyshare,
derivationPath: "m/1"
)

return dataBytes
}
case .failure(let error):
do {
// show error to user or abort process
Swift.print(error)
return nil
}
}
}
  • When duoSession.sign() is called with a derivationPath, the signature is generated for the specified BIP32 derivation path.
  • derivationPath is a string that specifies the path to the child key. It defaults to 'm' (no derivation) if not provided.