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
orSilentShard.EdDSA.deriveChildPublicKeyAsData
which returnsResult
ofSuccess
with Child Public-Key bytes asData
or Failure witherror
. - You can get public key as various string formats :
Hex
String - By usingSilentShardDuo.ECDSA.deriveChildPublicKeyAsHex()
//or
SilentShardDuo.EdDSA.deriveChildPublicKeyAsHex()Base64
String - By usingSilentShardDuo.ECDSA.deriveChildPublicKeyAsBase64()
//or
SilentShardDuo.EdDSA.deriveChildPublicKeyAsBase64()UrlSafeBase64
String -SilentShardDuo.ECDSA.deriveChildPublicKeyAsUrlSafeBase64()
//or
SilentShardDuo.EdDSA.deriveChildPublicKeyAsUrlSafeBase64()Result
ofSuccess
with Child Public-Key asString
in desired format orFailure
witherror
Example
- ECDSA
- EdDSA
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
}
}
}
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.EdDSA
.deriveChildPublicKeyAsHex(
keyshare,
derivationPath: "m/1"
)
// bytes
let childPublicKeyAsData = await SilentShardDuo.EdDSA
.deriveChildPublicKeyAsData(
keyshare,
derivationPath: "m/1"
)
// base64 string
let childPublicKeyAsDataAsBase64String =
await SilentShardDuo.EdDSA.deriveChildPublicKeyAsBase64(
keyshare,
derivationPath: "m/1"
)
// url safe base64 string
let childPublicKeyAsDataAsUrlSafeBase64String =
await SilentShardDuo.EdDSA
.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 aderivationPath
, 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.