Skip to content

Commit

Permalink
[FOLD] move receipt asn.1 definition to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonianb committed Apr 21, 2020
1 parent 67e7dce commit b4952fd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
35 changes: 3 additions & 32 deletions asn1/Stream.asn
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ IMPORTS
UInt8,
UInt96,
UInt128,
UInt256,
VarUInt,
VarBytes
FROM GenericTypes

Address
FROM InterledgerTypes

Receipt
FROM StreamReceipt
;

StreamEncryptionEnvelope ::= SEQUENCE {
Expand Down Expand Up @@ -77,37 +79,6 @@ StreamFrame ::= SEQUENCE {
data FRAME.&Type ({FrameSet}{@type})
}

RECEIPT ::= CLASS {
&typeId UInt8 UNIQUE,
&Type
} WITH SYNTAX {&typeId &Type}

ReceiptSet RECEIPT ::= {
{1 ReceiptV1}
}

Receipt ::= SEQUENCE {
type RECEIPT.&typeId ({ReceiptSet}),
-- NOT length-prefixed
data RECEIPT.&Type ({ReceiptSet}{@type})
}

ReceiptV1 ::= SEQUENCE {
-- Identifier of the connection
nonce UInt128,

-- Identifier of the stream
streamId UInt8,

-- Total amount the stream has received so far
totalReceived UInt64,

-- HMAC-SHA256 using a 32 byte Secret
-- The message is the concatenation of the 1 byte type/version (always 1) and all other fields,
-- in the order listed above
hmac UInt256
}

ConnectionError ::= SEQUENCE {
-- Numeric error code
code UInt8,
Expand Down
45 changes: 45 additions & 0 deletions asn1/StreamReceipt.asn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
StreamReceipt
DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN

IMPORTS
UInt8,
UInt64,
UInt128,
UInt256
FROM GenericTypes
;

RECEIPT ::= CLASS {
&typeId UInt8 UNIQUE,
&Type
} WITH SYNTAX {&typeId &Type}

ReceiptSet RECEIPT ::= {
{1 ReceiptV1}
}

Receipt ::= SEQUENCE {
type RECEIPT.&typeId ({ReceiptSet}),
-- NOT length-prefixed
data RECEIPT.&Type ({ReceiptSet}{@type})
}

ReceiptV1 ::= SEQUENCE {
-- Identifier of the connection
nonce UInt128,

-- Identifier of the stream
streamId UInt8,

-- Total amount the stream has received so far
totalReceived UInt64,

-- HMAC-SHA256 using a 32 byte Secret
-- The message is the concatenation of the 1 byte type/version (always 1) and all other fields,
-- in the order listed above
hmac UInt256
}

END

0 comments on commit b4952fd

Please sign in to comment.