raw property

  1. @override
Uint8List get raw
override

The key as DER PKIX (SubjectPublicKeyInfo), as go-libp2p marshals it.

Implementation

@override
Uint8List get raw {
  try {
    final params = _key.parameters!;
    final algorithm = pc.ASN1Sequence()
      ..add(pc.ASN1ObjectIdentifier.fromIdentifierString(_ecPublicKeyOid))
      ..add(pc.ASN1ObjectIdentifier.fromIdentifierString(_curveOid(params)));
    final spki = pc.ASN1Sequence()
      ..add(algorithm)
      ..add(pc.ASN1BitString(stringValues: _encodePoint(params, _key.Q!)));
    return Uint8List.fromList(spki.encode());
  } catch (e) {
    throw ECDSAKeyException('Failed to encode ECDSA public key: ${e.toString()}');
  }
}