signPowerUpSignature static method

Uint8List signPowerUpSignature({
  1. required String senderDid,
  2. required String pairwiseDid,
  3. required String timestamp,
  4. required CommercioRSAPrivateKey rsaPrivateKey,
})

Takes senderDid, pairwiseDid, timestamp and:

  1. Concatenate senderDid, pairwiseDid and timestamp as payload
  2. Returns the RSA PKCS1v1.5 (the SHA256 digest is calculated inside the signer) and sign using the rsaPrivateKey

Implementation

static Uint8List signPowerUpSignature({
  required String senderDid,
  required String pairwiseDid,
  required String timestamp,
  required CommercioRSAPrivateKey rsaPrivateKey,
}) {
  final concat = senderDid + pairwiseDid + timestamp;

  final rsaSigner = RSASigner(SHA256Digest(), '0609608648016503040201');
  rsaSigner.init(
    true,
    PrivateKeyParameter<RSAPrivateKey>(rsaPrivateKey.privateKey),
  );

  final sig =
      rsaSigner.generateSignature(Uint8List.fromList(utf8.encode(concat)));

  return sig.bytes;
}