encodeSecp256k1PrivateKeyPkcs8 static method
Wraps a secp256k1 private key in a PKCS8 "PrivateKeyInfo". The curve OID lives in the AlgorithmIdentifier; the nested SEC1 structure omits it (matching common OpenSSL / RFC 5915 output).
Implementation
static SecretBytes encodeSecp256k1PrivateKeyPkcs8(
List<int> privateKey, {
List<int>? publicKeyPoint,
}) {
final algId = DerUtils.derSequence([
...DerUtils.derOid(Oids.ecPublicKey),
...DerUtils.derOid(Oids.secp256k1),
]);
final sec1 = encodeSecp256k1PrivateKeySec1(
privateKey,
publicKeyPoint: publicKeyPoint,
includeCurveOid: false,
);
return SecretBytes.take(
DerUtils.derSequence([
...DerUtils.derSmallInt(0),
...algId,
...DerUtils.derOctetString(sec1),
]),
);
}