COSEKey.fromEd25519Keypair constructor

COSEKey.fromEd25519Keypair({
  1. List<int>? publicKey,
  2. List<int>? privateKey,
  3. bool forSigning = false,
  4. bool forVerifying = false,
})

Implementation

factory COSEKey.fromEd25519Keypair(
    {List<int>? publicKey,
    List<int>? privateKey,
    bool forSigning = false,
    bool forVerifying = false}) {
  return COSEKey(
    keyType: COSELabelInt.fromInt(COSEKeyType.okp.value),
    algorithmId: COSELabelInt.fromInt(COSEAlgorithmId.eddsa.value),
    keyOps: forSigning || forVerifying
        ? COSELabels(labels: [
            if (forSigning) COSELabelInt.fromInt(COSEKeyOperation.sign.value),
            if (forVerifying)
              COSELabelInt.fromInt(COSEKeyOperation.verify.value)
          ])
        : null,
    otherHeaders: {
      COSELabelInt.fromInt(COSEECKey.crv.value):
          CborIntValue(COSECurveType.ed25519.value),
      if (publicKey != null)
        COSELabelInt.fromInt(COSEECKey.x.value): CborBytesValue(publicKey),
      if (privateKey != null)
        COSELabelInt.fromInt(COSEECKey.d.value): CborBytesValue(privateKey),
    },
  );
}