def aes_parse_encoder_fields_map
qasim-bend-kit@0.1.0.2 · proof/AES_EnvelopeProof.bend:989
import qasim-bend-kit@0.1.0.2/proof/AES_EnvelopeProof.bend as AESEnvelopeProof
import Base
import qasim-bend-kit@0.1.0.2/libs/AES256GCM.bend as AES
989def aes_parse_encoder_fields_map(+envelope: AES.Envelope) ->
990 {Result.map(&2, &2, AES.Error, AES.Envelope, String, AES.encode,
991 AES.parse_fields(["v1",
992 AES.hex_bytes(AES.fixed_bytes(12n,
993 AES.nonce_bytes(AES.envelope_nonce(envelope)))),
994 AES.hex_bytes(AES.fixed_bytes(16n,
995 AES.tag_bytes(AES.envelope_tag(envelope)))),
996 AES.hex_bytes(AES.ciphertext(envelope))])) ==
997 Done{AES.encode(envelope)} :
998 Result<&2, &2, AES.Error, String>}:
999 match envelope:
1000 case AES.Envelope{nonce, ciphertext, tag, valid}:
1001 match nonce:
1002 case AES.Nonce{nonce_bytes, nonce_size, nonce_valid}:
1003 aes_parse_fields_hex_map(
1004 AES.fixed_bytes(12n, nonce_bytes),
1005 AES.fixed_bytes(16n, AES.tag_bytes(tag)), ciphertext,
1006 aes_fixed_bytes_length(12n, nonce_bytes),
1007 aes_fixed_bytes_length(16n, AES.tag_bytes(tag)))