const IR = I.slice(I.byteLength / 2)
if (curve === 'ed25519 seed') {
return ({ privateKey: IL, chainCode: IR })
- } else {
- const ILparsed = parse256(new Uint8Array(IL))
- if (ILparsed >= Point.CURVE().n) {
- throw new Error('Invalid child key is greater than the order of the curve')
- }
- const pkParsed = parse256(pk)
- const childKey = (ILparsed + pkParsed) % Point.CURVE().n
- if (childKey === 0n) {
- throw new Error('Invalid child key is zero')
- }
- return ({ privateKey: ser256(childKey).buffer, chainCode: IR })
}
+ const ILparsed = parse256(new Uint8Array(IL))
+ if (ILparsed >= Point.CURVE().n) {
+ throw new Error('Invalid child key is greater than the order of the curve')
+ }
+ const pkParsed = parse256(pk)
+ const childKey = (ILparsed + pkParsed) % Point.CURVE().n
+ if (childKey === 0n) {
+ throw new Error('Invalid child key is zero')
+ }
+ return ({ privateKey: ser256(childKey).buffer, chainCode: IR })
}
function ser32 (integer: number): Bytes {