Proto.lean
Declarations on this page (140)
- structure PolynomialEncoder
- structure PolynomialDecoder
- structure KeysUnsampled
- structure HeaderSent
- structure EkSent
- structure EkSentCt1Received
- structure NoHeaderReceived
- structure HeaderReceived
- structure Ct1Sent
- structure Ct1SentEkReceived
- structure Ct2Sent
- structure KeysUnsampled
- structure KeysSampled
- structure HeaderSent
- structure Ct1Received
- structure EkSentCt1Received
- structure NoHeaderReceived
- structure HeaderReceived
- structure Ct1Sampled
- structure EkReceivedCt1Sampled
- structure Ct1Acknowledged
- structure Ct2Sampled
- inductive InnerState
- structure V1State
-
inductive PqRatchetState.
Inner - structure PqRatchetState
- inductive WireType
- def ofU64?
- def toU32
- inductive DecodeErr
- def RECURSION_LIMIT
- def MIN_TAG
- def decodeVarintAux
- def decodeVarint
- def encodeVarintAux
- def encodeVarint
- def decodeKey
- def encodeKey
- def checkWireType
- def takeExact
- def dropExact
- def skipGroupLoop
- def skipFieldNonGroup
- def skipFieldAux
- def skipField
- def mergeUint32
- def mergeUint64
- def mergeInt32
- def mergeBool
- def mergeBytes
- def mergeRepeatedBytes
- def encodeUint32Field
- def encodeUint64Field
- def encodeInt32Field
- def encodeBoolField
- def encodeBytesUncond
- def encodeBytesField
- def encodeRepeatedBytes
- def mergeFieldsLoop
- def mergeMessage
- def mergeOptMessage
- def mergeRepeatedMessage
- def encodeMessage
- def encodeOptMessage
- def encodeRepeatedMessage
- def mergeTopLevelMessage
- def decodeTopLevelMessage
- abbrev WireType
- abbrev DecodeErr
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def merge
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def mergeField
- def encodeRaw
- def merge
- def encode
- def mergeField
- def decode
- def encodeRaw
- def merge
- def encode
- def mergeField
- def decode
- def encodeRaw
- def encode
- def decodeState
- def spqrDecodeState
- def encodeState
SPQR V1: Protobuf types and prost 0.14.4 codec for pq_ratchet.
Trusted in part. The theorems of Computational/ use only part of this file (see Computational/): the message types (PolynomialEncoder, PolynomialDecoder, ProtoChunk, V1State, InnerState, PqRatchetState) and the encodeRaw / mergeField codec functions (WireType, DecodeErr, decodeVarint, encodeVarint, decodeKey, encodeKey, skipField, mergeFieldsLoop, mergeMessage, mergeTopLevelMessage, decodeTopLevelMessage, encodeMessage, decodeState, encodeState) that the SPQR V1 state goes through. The remaining definitions (encode, decode, encodedLen, merge, V1Msg, decodeV1Msg, encodeV1Msg, and spqrDecodeState) are checked by Lean.
@[expose] public sectionnamespace CryptoVerification.LibsignalSpqrV16 declarations not shown (lines 40–45): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
structure PolynomialEncoder
message PolynomialEncoder (src/).
1 declaration not shown (lines 54–54): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
structure PolynomialDecoder
message PolynomialDecoder (src/).
structure PolynomialDecoder where
ptsNeeded : BitVec 32 := 0#32
polys : BitVec 32 := 0#32
pts : List Bytes := []
isComplete : Bool := false
deriving DecidableEq, Repr, Inhabited5 declarations not shown (lines 64–91): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace V1State.Unchunkedstructure KeysUnsampled
structure KeysUnsampled where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
deriving DecidableEq, Repr, Inhabitedstructure HeaderSent
structure HeaderSent where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
ek : Bytes := []
dk : Bytes := []
deriving DecidableEq, Repr, Inhabitedstructure EkSent
structure EkSent where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
dk : Bytes := []
deriving DecidableEq, Repr, Inhabitedstructure EkSentCt1Received
structure EkSentCt1Received where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
dk : Bytes := []
ct1 : Bytes := []
deriving DecidableEq, Repr, Inhabitedstructure NoHeaderReceived
structure NoHeaderReceived where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
deriving DecidableEq, Repr, Inhabitedstructure HeaderReceived
structure HeaderReceived where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
hdr : Bytes := []
deriving DecidableEq, Repr, Inhabited1 declaration not shown (lines 124–129): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
structure Ct1Sent
structure Ct1Sent where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
hdr : Bytes := []
es : Bytes := []
ct1 : Bytes := []
deriving DecidableEq, Repr, Inhabitedstructure Ct1SentEkReceived
structure Ct1SentEkReceived where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
es : Bytes := []
ek : Bytes := []
ct1 : Bytes := []
deriving DecidableEq, Repr, Inhabitedstructure Ct2Sent
structure Ct2Sent where
epoch : Epoch := 0#64
auth : Option ProtoAuthenticator := none
deriving DecidableEq, Repr, Inhabitedend V1State.Unchunked1 declaration not shown (lines 150–152): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
namespace V1State.Chunkedstructure KeysUnsampled
structure KeysUnsampled where
uc : Option V1State.Unchunked.KeysUnsampled := none
deriving DecidableEq, Repr, Inhabitedstructure KeysSampled
structure KeysSampled where
uc : Option V1State.Unchunked.HeaderSent := none
sendingHdr : Option PolynomialEncoder := none
deriving DecidableEq, Repr, Inhabitedstructure HeaderSent
structure HeaderSent where
uc : Option V1State.Unchunked.EkSent := none
sendingEk : Option PolynomialEncoder := none
receivingCt1 : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure Ct1Received
structure Ct1Received where
uc : Option V1State.Unchunked.EkSentCt1Received := none
sendingEk : Option PolynomialEncoder := none
deriving DecidableEq, Repr, Inhabitedstructure EkSentCt1Received
V1State. (pq_ratchet.): tags uc = 1, receiving_ct2 = 3.
structure EkSentCt1Received where
uc : Option V1State.Unchunked.EkSentCt1Received := none
receivingCt2 : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure NoHeaderReceived
structure NoHeaderReceived where
uc : Option V1State.Unchunked.NoHeaderReceived := none
receivingHdr : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure HeaderReceived
structure HeaderReceived where
uc : Option V1State.Unchunked.HeaderReceived := none
receivingEk : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure Ct1Sampled
structure Ct1Sampled where
uc : Option V1State.Unchunked.Ct1Sent := none
sendingCt1 : Option PolynomialEncoder := none
receivingEk : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure EkReceivedCt1Sampled
structure EkReceivedCt1Sampled where
uc : Option V1State.Unchunked.Ct1SentEkReceived := none
sendingCt1 : Option PolynomialEncoder := none
deriving DecidableEq, Repr, Inhabitedstructure Ct1Acknowledged
structure Ct1Acknowledged where
uc : Option V1State.Unchunked.Ct1Sent := none
receivingEk : Option PolynomialDecoder := none
deriving DecidableEq, Repr, Inhabitedstructure Ct2Sampled
structure Ct2Sampled where
uc : Option V1State.Unchunked.Ct2Sent := none
sendingCt2 : Option PolynomialEncoder := none
deriving DecidableEq, Repr, Inhabitedend V1State.Chunkednamespace V1Stateinductive InnerState
oneof V1State. (src/).
inductive InnerState where
| keysUnsampled (v : Chunked.KeysUnsampled)
| keysSampled (v : Chunked.KeysSampled)
| headerSent (v : Chunked.HeaderSent)
| ct1Received (v : Chunked.Ct1Received)
| ekSentCt1Received (v : Chunked.EkSentCt1Received)
| noHeaderReceived (v : Chunked.NoHeaderReceived)
| headerReceived (v : Chunked.HeaderReceived)
| ct1Sampled (v : Chunked.Ct1Sampled)
| ekReceivedCt1Sampled (v : Chunked.EkReceivedCt1Sampled)
| ct1Acknowledged (v : Chunked.Ct1Acknowledged)
| ct2Sampled (v : Chunked.Ct2Sampled)
deriving DecidableEq, Reprend V1Statestructure V1State
message V1State (src/).
structure V1State where
innerState : Option V1State.InnerState := none
deriving DecidableEq, Repr, Inhabited1 declaration not shown (lines 225–225): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
inductive PqRatchetState.
oneof PqRatchetState. (src/).
inductive PqRatchetState.Inner where
| v1 (v : V1State)
deriving DecidableEq, Reprstructure PqRatchetState
message PqRatchetState (src/).
structure PqRatchetState where
versionNegotiation : Option VersionNegotiationPB := none
chain : Option ChainPB := none
inner : Option PqRatchetState.Inner := none
deriving DecidableEq, Repr, Inhabitednamespace Proto6 declarations not shown (lines 243–248): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
inductive WireType
prost::encoding::WireType.
inductive WireType where
| varint | SixtyFourBit | lengthDelimited | startGroup | endGroup | ThirtyTwoBit
deriving DecidableEq, Repr, Inhabitednamespace WireTypedef ofU64?
def ofU64? (v : BitVec 64) : Option WireType :=
if v == 0#64 then some .varint else if v == 1#64 then some .SixtyFourBit
else if v == 2#64 then some .lengthDelimited else if v == 3#64 then some .startGroup
else if v == 4#64 then some .endGroup else if v == 5#64 then some .ThirtyTwoBit else nonedef toU32
def toU32 : WireType → BitVec 32
| .varint => 0#32 | .SixtyFourBit => 1#32 | .lengthDelimited => 2#32
| .startGroup => 3#32 | .endGroup => 4#32 | .ThirtyTwoBit => 5#32end WireTypeinductive DecodeErr
prost::DecodeError kinds.
inductive DecodeErr where
| invalidVarint | bufferUnderflow | invalidWireType (v : BitVec 64)
| invalidKey (key : BitVec 64) | invalidTag (tag : BitVec 32)
| unexpectedWireType (expected actual : WireType) | unexpectedEndGroupTag | recursionLimitExceeded
deriving DecidableEq, Repr, Inhabiteddef RECURSION_LIMIT
def RECURSION_LIMIT : Nat := 100def MIN_TAG
def MIN_TAG : BitVec 32 := 1#32def decodeVarintAux
LEB128 varint decoder (prost::encoding::varint::decode_varint_slow): 1 to 10 bytes, with the 10th byte required to be < 0x02.
def decodeVarintAux : Nat → Nat → BitVec 64 → Bytes → Except DecodeErr (BitVec 64 × Bytes)
| 0, _, _, _ => .error .invalidVarint
| fuel + 1, idx, acc, bs =>
match bs with
| [] => .error .bufferUnderflow
| b :: rest =>
if idx == 9 then
if b ≥ 0x02#8 then .error .invalidVarint
else .ok (acc ||| ((b &&& 0x7f#8).zeroExtend 64 <<< 63), rest)
else
let acc' := acc ||| ((b &&& 0x7f#8).zeroExtend 64 <<< (idx * 7))
if b < 0x80#8 then .ok (acc', rest)
else decodeVarintAux fuel (idx + 1) acc' restdef decodeVarint
def decodeVarint (bs : Bytes) : Except DecodeErr (BitVec 64 × Bytes) := decodeVarintAux 10 0 0#64 bsdef encodeVarintAux
def encodeVarintAux : Nat → BitVec 64 → Bytes
| 0, v => [v.truncate 8]
| fuel + 1, v =>
if v < 0x80#64 then [v.truncate 8]
else ((v.truncate 8 ||| 0x80#8)) :: encodeVarintAux fuel (v >>> 7)def encodeVarint
prost::encoding::varint::encode_varint.
def encodeVarint (v : BitVec 64) : Bytes := encodeVarintAux 10 v1 declaration not shown (lines 301–301): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def decodeKey
prost::encoding::decode_key: validates key ≤ u32::MAX, 3-bit WireType, and tag ≥ 1.
def decodeKey (bs : Bytes) : Except DecodeErr ((BitVec 32 × WireType) × Bytes) := do
let (key, rest) ← decodeVarint bs
if key > 0xffffffff#64 then .error (.invalidKey key)
else
let wt ← match WireType.ofU64? (key &&& 0x7#64) with
| some w => .ok w
| none => .error (.invalidWireType (key &&& 0x7#64))
let tag : BitVec 32 := (key >>> 3).truncate 32
if tag < MIN_TAG then .error (.invalidTag tag) else .ok ((tag, wt), rest)def encodeKey
def encodeKey (tag : BitVec 32) (wt : WireType) : Bytes :=
encodeVarint (((tag <<< 3) ||| wt.toU32).zeroExtend 64)1 declaration not shown (lines 316–316): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def checkWireType
def checkWireType (expected actual : WireType) : Except DecodeErr Unit :=
if expected != actual then .error (.unexpectedWireType expected actual) else .ok ()def takeExact
def dropExact
def dropExact : Nat → Bytes → Except DecodeErr Bytes
| 0, bs => .ok bs
| _ + 1, [] => .error .bufferUnderflow
| n + 1, _ :: rest => dropExact n restdef skipGroupLoop
def skipGroupLoop (skipInner : WireType → BitVec 32 → Bytes → Except DecodeErr Bytes) :
Nat → BitVec 32 → Bytes → Except DecodeErr Bytes
| 0, _, _ => .error .bufferUnderflow
| fuel + 1, groupTag, bs => do
let ((innerTag, innerWt), rest) ← decodeKey bs
if innerWt == .endGroup then
if innerTag != groupTag then .error .unexpectedEndGroupTag else .ok rest
else do
let rest' ← skipInner innerWt innerTag rest
skipGroupLoop skipInner fuel groupTag rest'def skipFieldNonGroup
def skipFieldNonGroup (wt : WireType) (bs : Bytes) : Except DecodeErr Bytes :=
match wt with
| .varint => do let (_, rest) ← decodeVarint bs; .ok rest
| .ThirtyTwoBit => dropExact 4 bs
| .SixtyFourBit => dropExact 8 bs
| .lengthDelimited => do let (len, rest) ← decodeVarint bs; dropExact len.toNat rest
| _ => .error .unexpectedEndGroupTagdef skipFieldAux
prost::encoding::skip_field, checking depth > 0 before dispatching on wt.
def skipFieldAux : Nat → WireType → BitVec 32 → Bytes → Except DecodeErr Bytes
| 0, _, _, _ => .error .recursionLimitExceeded
| depth' + 1, wt, tag, bs =>
if wt == .startGroup then skipGroupLoop (skipFieldAux depth') bs.length tag bs
else skipFieldNonGroup wt bsdef skipField
def skipField (wt : WireType) (tag : BitVec 32) (bs : Bytes) (depth : Nat) : Except DecodeErr Bytes :=
skipFieldAux depth wt tag bsdef mergeUint32
def mergeUint32 (wt : WireType) (bs : Bytes) : Except DecodeErr (BitVec 32 × Bytes) := do
checkWireType .varint wt; let (v, rest) ← decodeVarint bs; .ok (v.truncate 32, rest)def mergeUint64
def mergeUint64 (wt : WireType) (bs : Bytes) : Except DecodeErr (BitVec 64 × Bytes) := do
checkWireType .varint wt; decodeVarint bsdef mergeInt32
def mergeInt32 (wt : WireType) (bs : Bytes) : Except DecodeErr (BitVec 32 × Bytes) := do
checkWireType .varint wt; let (v, rest) ← decodeVarint bs; .ok (v.truncate 32, rest)def mergeBool
def mergeBool (wt : WireType) (bs : Bytes) : Except DecodeErr (Bool × Bytes) := do
checkWireType .varint wt; let (v, rest) ← decodeVarint bs; .ok (v != 0#64, rest)def mergeBytes
def mergeBytes (wt : WireType) (bs : Bytes) : Except DecodeErr (Bytes × Bytes) := do
checkWireType .lengthDelimited wt; let (len, rest) ← decodeVarint bs; takeExact len.toNat restdef mergeRepeatedBytes
def encodeUint32Field
def encodeUint32Field (tag : BitVec 32) (v : BitVec 32) : Bytes :=
if v == 0#32 then [] else encodeKey tag .varint ++ encodeVarint (v.zeroExtend 64)def encodeUint64Field
def encodeUint64Field (tag : BitVec 32) (v : BitVec 64) : Bytes :=
if v == 0#64 then [] else encodeKey tag .varint ++ encodeVarint vdef encodeInt32Field
def encodeInt32Field (tag : BitVec 32) (v : BitVec 32) : Bytes :=
if v == 0#32 then [] else encodeKey tag .varint ++ encodeVarint (v.signExtend 64)def encodeBoolField
1 declaration not shown (lines 382–384): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeBytesUncond
def encodeBytesUncond (tag : BitVec 32) (v : Bytes) : Bytes :=
encodeKey tag .lengthDelimited ++ encodeVarint (BitVec.ofNat 64 v.length) ++ vdef encodeBytesField
def encodeBytesField (tag : BitVec 32) (v : Bytes) : Bytes :=
if v.isEmpty then [] else encodeBytesUncond tag vdef encodeRepeatedBytes
def encodeRepeatedBytes (tag : BitVec 32) (vs : List Bytes) : Bytes :=
vs.foldr (fun v acc => encodeBytesUncond tag v ++ acc) []def mergeFieldsLoop
def mergeFieldsLoop {M : Type}
(mergeField : M → BitVec 32 → WireType → Bytes → Nat → Except DecodeErr (M × Bytes)) :
Nat → M → Bytes → Nat → Except DecodeErr M
| _, m, [], _ => .ok m
| 0, _, _ :: _, _ => .error .bufferUnderflow
| fuel + 1, m, bs, depth => do
let ((tag, wt), rest) ← decodeKey bs
let (m', rest') ← mergeField m tag wt rest depth
mergeFieldsLoop mergeField fuel m' rest' depthdef mergeMessage
prost::encoding::message::merge: decodes a length-prefixed nested message with recursion budget depth.
def mergeMessage {M : Type}
(mergeField : M → BitVec 32 → WireType → Bytes → Nat → Except DecodeErr (M × Bytes))
(wt : WireType) (m : M) (bs : Bytes) (depth : Nat) : Except DecodeErr (M × Bytes) := do
checkWireType .lengthDelimited wt
match depth with
| 0 => .error .recursionLimitExceeded
| depth' + 1 => do
let (len, rest) ← decodeVarint bs
let (sub, after) ← takeExact len.toNat rest
let m' ← mergeFieldsLoop mergeField sub.length m sub depth'
.ok (m', after)def mergeOptMessage
def mergeOptMessage {M : Type} [Inhabited M]
(mergeField : M → BitVec 32 → WireType → Bytes → Nat → Except DecodeErr (M × Bytes))
(wt : WireType) (opt : Option M) (bs : Bytes) (depth : Nat) :
Except DecodeErr (Option M × Bytes) := do
let (m', rest) ← mergeMessage mergeField wt (opt.getD default) bs depth; .ok (some m', rest)def mergeRepeatedMessage
def mergeRepeatedMessage {M : Type} [Inhabited M]
(mergeField : M → BitVec 32 → WireType → Bytes → Nat → Except DecodeErr (M × Bytes))
(wt : WireType) (ms : List M) (bs : Bytes) (depth : Nat) :
Except DecodeErr (List M × Bytes) := do
let (m', rest) ← mergeMessage mergeField wt default bs depth; .ok (ms ++ [m'], rest)def encodeMessage
def encodeMessage {M : Type} (encodeRaw : M → Bytes) (tag : BitVec 32) (m : M) : Bytes :=
let raw := encodeRaw m
encodeKey tag .lengthDelimited ++ encodeVarint (BitVec.ofNat 64 raw.length) ++ rawdef encodeOptMessage
def encodeOptMessage {M : Type} (encodeRaw : M → Bytes) (tag : BitVec 32) : Option M → Bytes
| none => [] | some m => encodeMessage encodeRaw tag mdef encodeRepeatedMessage
def encodeRepeatedMessage {M : Type} (encodeRaw : M → Bytes) (tag : BitVec 32) (ms : List M) : Bytes :=
ms.foldr (fun m acc => encodeMessage encodeRaw tag m ++ acc) []def mergeTopLevelMessage
def mergeTopLevelMessage {M : Type}
(mergeField : M → BitVec 32 → WireType → Bytes → Nat → Except DecodeErr (M × Bytes))
(m : M) (bs : Bytes) : Except DecodeErr M :=
mergeFieldsLoop mergeField bs.length m bs RECURSION_LIMITdef decodeTopLevelMessage
end Protoabbrev WireType
abbrev WireType := Proto.WireTypeabbrev DecodeErr
abbrev DecodeErr := Proto.DecodeErrnamespace PolynomialEncoderdef mergeField
open Proto in
def mergeField (m : PolynomialEncoder) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (PolynomialEncoder × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with idx := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeRepeatedBytes wt m.pts bs; .ok ({ m with pts := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeRepeatedBytes wt m.polys bs; .ok ({ m with polys := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 460–461): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : PolynomialEncoder) : Bytes :=
Proto.encodeUint32Field 1#32 m.idx ++ Proto.encodeRepeatedBytes 2#32 m.pts ++ Proto.encodeRepeatedBytes 3#32 m.polys2 declarations not shown (lines 464–465): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end PolynomialEncodernamespace PolynomialDecoderdef mergeField
open Proto in
def mergeField (m : PolynomialDecoder) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (PolynomialDecoder × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with ptsNeeded := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with polys := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeRepeatedBytes wt m.pts bs; .ok ({ m with pts := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBool wt bs; .ok ({ m with isComplete := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 477–478): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : PolynomialDecoder) : Bytes :=
Proto.encodeUint32Field 1#32 m.ptsNeeded ++ Proto.encodeUint32Field 2#32 m.polys ++
Proto.encodeRepeatedBytes 3#32 m.pts ++ Proto.encodeBoolField 4#32 m.isComplete2 declarations not shown (lines 482–483): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end PolynomialDecodernamespace ChainParamsPBdef mergeField
open Proto in
def mergeField (m : ChainParamsPB) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (ChainParamsPB × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with maxJump := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with maxOooKeys := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 493–494): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : ChainParamsPB) : Bytes := Proto.encodeUint32Field 1#32 m.maxJump ++ Proto.encodeUint32Field 2#32 m.maxOooKeys2 declarations not shown (lines 496–497): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end ChainParamsPB6 declarations not shown (lines 501–506): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace EpochDirectionPBdef mergeField
open Proto in
def mergeField (m : EpochDirectionPB) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (EpochDirectionPB × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint32 wt bs; .ok ({ m with ctr := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with next := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with prev := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 517–518): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : EpochDirectionPB) : Bytes :=
Proto.encodeUint32Field 1#32 m.ctr ++ Proto.encodeBytesField 2#32 m.next ++ Proto.encodeBytesField 3#32 m.prev2 declarations not shown (lines 521–522): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end EpochDirectionPB6 declarations not shown (lines 526–531): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace ChainEpochPBdef mergeField
open Proto in
def mergeField (m : ChainEpochPB) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (ChainEpochPB × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage EpochDirectionPB.mergeField wt m.send bs depth; .ok ({ m with send := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage EpochDirectionPB.mergeField wt m.recv bs depth; .ok ({ m with recv := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 541–542): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : ChainEpochPB) : Bytes :=
Proto.encodeOptMessage EpochDirectionPB.encodeRaw 1#32 m.send ++ Proto.encodeOptMessage EpochDirectionPB.encodeRaw 2#32 m.recv2 declarations not shown (lines 545–546): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end ChainEpochPB6 declarations not shown (lines 550–555): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace ChainPBdef mergeField
open Proto in
def mergeField (m : ChainPB) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (ChainPB × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeInt32 wt bs; .ok ({ m with direction := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with currentEpoch := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeRepeatedMessage ChainEpochPB.mergeField wt m.links bs depth; .ok ({ m with links := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with nextRoot := v }, bs')
else if tag == 5#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with sendEpoch := v }, bs')
else if tag == 6#32 then let (v, bs') ← mergeOptMessage ChainParamsPB.mergeField wt m.params bs depth; .ok ({ m with params := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 569–570): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : ChainPB) : Bytes :=
Proto.encodeInt32Field 1#32 m.direction ++ Proto.encodeUint64Field 2#32 m.currentEpoch ++
Proto.encodeRepeatedMessage ChainEpochPB.encodeRaw 3#32 m.links ++
Proto.encodeBytesField 4#32 m.nextRoot ++ Proto.encodeUint64Field 5#32 m.sendEpoch ++
Proto.encodeOptMessage ChainParamsPB.encodeRaw 6#32 m.params2 declarations not shown (lines 576–577): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end ChainPB6 declarations not shown (lines 581–586): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace VersionNegotiationPBdef mergeField
open Proto in
def mergeField (m : VersionNegotiationPB) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (VersionNegotiationPB × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with authKey := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeInt32 wt bs; .ok ({ m with direction := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeInt32 wt bs; .ok ({ m with minVersion := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeOptMessage ChainParamsPB.mergeField wt m.chainParams bs depth; .ok ({ m with chainParams := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 598–599): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : VersionNegotiationPB) : Bytes :=
Proto.encodeBytesField 1#32 m.authKey ++ Proto.encodeInt32Field 2#32 m.direction ++
Proto.encodeInt32Field 3#32 m.minVersion ++ Proto.encodeOptMessage ChainParamsPB.encodeRaw 4#32 m.chainParams2 declarations not shown (lines 603–604): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end VersionNegotiationPB12 declarations not shown (lines 608–627): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace V1Msg.InnerMsgdef merge
open Proto in
def merge (cur : Option V1Msg.InnerMsg) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (Option V1Msg.InnerMsg × Bytes) := do
if tag == 3#32 then
let prev := match cur with | some (.hdr v) => v | _ => default
let (v, rest) ← mergeMessage ProtoChunk.mergeField wt prev bs depth; .ok (some (.hdr v), rest)
else if tag == 4#32 then
let prev := match cur with | some (.ek v) => v | _ => default
let (v, rest) ← mergeMessage ProtoChunk.mergeField wt prev bs depth; .ok (some (.ek v), rest)
else if tag == 5#32 then
let prev := match cur with | some (.ekCt1Ack v) => v | _ => default
let (v, rest) ← mergeMessage ProtoChunk.mergeField wt prev bs depth; .ok (some (.ekCt1Ack v), rest)
else if tag == 6#32 then let (v, rest) ← mergeBool wt bs; .ok (some (.ct1Ack v), rest)
else if tag == 7#32 then
let prev := match cur with | some (.ct1 v) => v | _ => default
let (v, rest) ← mergeMessage ProtoChunk.mergeField wt prev bs depth; .ok (some (.ct1 v), rest)
else if tag == 8#32 then
let prev := match cur with | some (.ct2 v) => v | _ => default
let (v, rest) ← mergeMessage ProtoChunk.mergeField wt prev bs depth; .ok (some (.ct2 v), rest)
else let rest ← skipField wt tag bs depth; .ok (cur, rest)2 declarations not shown (lines 651–655): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end V1Msg.InnerMsg6 declarations not shown (lines 659–673): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace ProtoAuthenticatordef mergeField
open Proto in
def mergeField (m : ProtoAuthenticator) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (ProtoAuthenticator × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with rootKey := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with macKey := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')2 declarations not shown (lines 683–684): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
def encodeRaw
def encodeRaw (m : ProtoAuthenticator) : Bytes := Proto.encodeBytesField 1#32 m.rootKey ++ Proto.encodeBytesField 2#32 m.macKey2 declarations not shown (lines 686–687): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end ProtoAuthenticatornamespace V1State.Unchunkedopen Proto5 declarations not shown (lines 692–697): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace KeysUnsampleddef mergeField
def mergeField (m : KeysUnsampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (KeysUnsampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 704–704): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : KeysUnsampled) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth2 declarations not shown (lines 706–707): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end KeysUnsamplednamespace HeaderSentdef mergeField
def mergeField (m : HeaderSent) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (HeaderSent × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with ek := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with dk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 717–717): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : HeaderSent) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.ek ++ encodeBytesField 4#32 m.dk2 declarations not shown (lines 719–720): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end HeaderSentnamespace EkSentdef mergeField
def mergeField (m : EkSent) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (EkSent × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with dk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 729–729): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : EkSent) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.dk2 declarations not shown (lines 731–732): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end EkSentnamespace EkSentCt1Receiveddef mergeField
def mergeField (m : EkSentCt1Received) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (EkSentCt1Received × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with dk := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with ct1 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 742–742): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : EkSentCt1Received) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.dk ++ encodeBytesField 4#32 m.ct12 declarations not shown (lines 744–745): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end EkSentCt1Receivednamespace NoHeaderReceiveddef mergeField
def mergeField (m : NoHeaderReceived) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (NoHeaderReceived × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 753–753): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : NoHeaderReceived) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth2 declarations not shown (lines 755–756): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end NoHeaderReceivednamespace HeaderReceiveddef mergeField
def mergeField (m : HeaderReceived) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (HeaderReceived × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with hdr := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 765–765): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : HeaderReceived) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.hdr2 declarations not shown (lines 767–768): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end HeaderReceived5 declarations not shown (lines 772–781): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
namespace Ct1Sentdef mergeField
def mergeField (m : Ct1Sent) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct1Sent × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with hdr := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with es := v }, bs')
else if tag == 5#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with ct1 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 792–792): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct1Sent) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.hdr ++ encodeBytesField 4#32 m.es ++ encodeBytesField 5#32 m.ct12 declarations not shown (lines 794–795): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct1Sentnamespace Ct1SentEkReceiveddef mergeField
def mergeField (m : Ct1SentEkReceived) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct1SentEkReceived × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with es := v }, bs')
else if tag == 4#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with ek := v }, bs')
else if tag == 5#32 then let (v, bs') ← mergeBytes wt bs; .ok ({ m with ct1 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 806–806): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct1SentEkReceived) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth ++ encodeBytesField 3#32 m.es ++ encodeBytesField 4#32 m.ek ++ encodeBytesField 5#32 m.ct12 declarations not shown (lines 808–809): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct1SentEkReceivednamespace Ct2Sentdef mergeField
def mergeField (m : Ct2Sent) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct2Sent × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeUint64 wt bs; .ok ({ m with epoch := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage ProtoAuthenticator.mergeField wt m.auth bs depth; .ok ({ m with auth := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 817–817): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct2Sent) : Bytes := encodeUint64Field 1#32 m.epoch ++ encodeOptMessage ProtoAuthenticator.encodeRaw 2#32 m.auth2 declarations not shown (lines 819–820): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct2Sentend V1State.Unchunkednamespace V1State.Chunkedopen Protonamespace KeysUnsampleddef mergeField
def mergeField (m : KeysUnsampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (KeysUnsampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.KeysUnsampled.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs') else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 829–829): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : KeysUnsampled) : Bytes := encodeOptMessage Unchunked.KeysUnsampled.encodeRaw 1#32 m.uc2 declarations not shown (lines 831–832): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end KeysUnsamplednamespace KeysSampleddef mergeField
def mergeField (m : KeysSampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (KeysSampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.HeaderSent.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingHdr bs depth; .ok ({ m with sendingHdr := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 840–840): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : KeysSampled) : Bytes := encodeOptMessage Unchunked.HeaderSent.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingHdr2 declarations not shown (lines 842–843): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end KeysSamplednamespace HeaderSentdef mergeField
def mergeField (m : HeaderSent) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (HeaderSent × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.EkSent.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingEk bs depth; .ok ({ m with sendingEk := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingCt1 bs depth; .ok ({ m with receivingCt1 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 852–852): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : HeaderSent) : Bytes := encodeOptMessage Unchunked.EkSent.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingEk ++ encodeOptMessage PolynomialDecoder.encodeRaw 3#32 m.receivingCt12 declarations not shown (lines 854–855): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end HeaderSentnamespace Ct1Receiveddef mergeField
def mergeField (m : Ct1Received) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct1Received × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.EkSentCt1Received.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingEk bs depth; .ok ({ m with sendingEk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 863–863): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct1Received) : Bytes := encodeOptMessage Unchunked.EkSentCt1Received.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingEk2 declarations not shown (lines 865–866): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct1Receivednamespace EkSentCt1Receiveddef mergeField
def mergeField (m : EkSentCt1Received) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (EkSentCt1Received × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.EkSentCt1Received.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingCt2 bs depth; .ok ({ m with receivingCt2 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 874–874): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : EkSentCt1Received) : Bytes := encodeOptMessage Unchunked.EkSentCt1Received.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialDecoder.encodeRaw 3#32 m.receivingCt22 declarations not shown (lines 876–877): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end EkSentCt1Receivednamespace NoHeaderReceiveddef mergeField
def mergeField (m : NoHeaderReceived) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (NoHeaderReceived × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.NoHeaderReceived.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingHdr bs depth; .ok ({ m with receivingHdr := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 885–885): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : NoHeaderReceived) : Bytes := encodeOptMessage Unchunked.NoHeaderReceived.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialDecoder.encodeRaw 2#32 m.receivingHdr2 declarations not shown (lines 887–888): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end NoHeaderReceivednamespace HeaderReceiveddef mergeField
def mergeField (m : HeaderReceived) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (HeaderReceived × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.HeaderReceived.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingEk bs depth; .ok ({ m with receivingEk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 896–896): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : HeaderReceived) : Bytes := encodeOptMessage Unchunked.HeaderReceived.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialDecoder.encodeRaw 2#32 m.receivingEk2 declarations not shown (lines 898–899): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end HeaderReceivednamespace Ct1Sampleddef mergeField
def mergeField (m : Ct1Sampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct1Sampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.Ct1Sent.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingCt1 bs depth; .ok ({ m with sendingCt1 := v }, bs')
else if tag == 3#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingEk bs depth; .ok ({ m with receivingEk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 908–908): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct1Sampled) : Bytes := encodeOptMessage Unchunked.Ct1Sent.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingCt1 ++ encodeOptMessage PolynomialDecoder.encodeRaw 3#32 m.receivingEk2 declarations not shown (lines 910–911): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct1Samplednamespace EkReceivedCt1Sampleddef mergeField
def mergeField (m : EkReceivedCt1Sampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (EkReceivedCt1Sampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.Ct1SentEkReceived.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingCt1 bs depth; .ok ({ m with sendingCt1 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 919–919): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : EkReceivedCt1Sampled) : Bytes := encodeOptMessage Unchunked.Ct1SentEkReceived.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingCt12 declarations not shown (lines 921–922): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end EkReceivedCt1Samplednamespace Ct1Acknowledgeddef mergeField
def mergeField (m : Ct1Acknowledged) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct1Acknowledged × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.Ct1Sent.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialDecoder.mergeField wt m.receivingEk bs depth; .ok ({ m with receivingEk := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 930–930): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct1Acknowledged) : Bytes := encodeOptMessage Unchunked.Ct1Sent.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialDecoder.encodeRaw 2#32 m.receivingEk2 declarations not shown (lines 932–933): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct1Acknowledgednamespace Ct2Sampleddef mergeField
def mergeField (m : Ct2Sampled) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) : Except DecodeErr (Ct2Sampled × Bytes) := do
if tag == 1#32 then let (v, bs') ← mergeOptMessage Unchunked.Ct2Sent.mergeField wt m.uc bs depth; .ok ({ m with uc := v }, bs')
else if tag == 2#32 then let (v, bs') ← mergeOptMessage PolynomialEncoder.mergeField wt m.sendingCt2 bs depth; .ok ({ m with sendingCt2 := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 941–941): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encodeRaw
def encodeRaw (m : Ct2Sampled) : Bytes := encodeOptMessage Unchunked.Ct2Sent.encodeRaw 1#32 m.uc ++ encodeOptMessage PolynomialEncoder.encodeRaw 2#32 m.sendingCt22 declarations not shown (lines 943–944): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Ct2Sampledend V1State.Chunkednamespace V1State.InnerStatedef merge
open Proto in
def merge (cur : Option V1State.InnerState) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (Option V1State.InnerState × Bytes) := do
if tag == 1#32 then
let (v, bs') ← mergeMessage Chunked.KeysUnsampled.mergeField wt (match cur with | some (.keysUnsampled v) => v | _ => default) bs depth; .ok (some (.keysUnsampled v), bs')
else if tag == 2#32 then
let (v, bs') ← mergeMessage Chunked.KeysSampled.mergeField wt (match cur with | some (.keysSampled v) => v | _ => default) bs depth; .ok (some (.keysSampled v), bs')
else if tag == 3#32 then
let (v, bs') ← mergeMessage Chunked.HeaderSent.mergeField wt (match cur with | some (.headerSent v) => v | _ => default) bs depth; .ok (some (.headerSent v), bs')
else if tag == 4#32 then
let (v, bs') ← mergeMessage Chunked.Ct1Received.mergeField wt (match cur with | some (.ct1Received v) => v | _ => default) bs depth; .ok (some (.ct1Received v), bs')
else if tag == 5#32 then
let (v, bs') ← mergeMessage Chunked.EkSentCt1Received.mergeField wt (match cur with | some (.ekSentCt1Received v) => v | _ => default) bs depth; .ok (some (.ekSentCt1Received v), bs')
else if tag == 6#32 then
let (v, bs') ← mergeMessage Chunked.NoHeaderReceived.mergeField wt (match cur with | some (.noHeaderReceived v) => v | _ => default) bs depth; .ok (some (.noHeaderReceived v), bs')
else if tag == 7#32 then
let (v, bs') ← mergeMessage Chunked.HeaderReceived.mergeField wt (match cur with | some (.headerReceived v) => v | _ => default) bs depth; .ok (some (.headerReceived v), bs')
else if tag == 8#32 then
let (v, bs') ← mergeMessage Chunked.Ct1Sampled.mergeField wt (match cur with | some (.ct1Sampled v) => v | _ => default) bs depth; .ok (some (.ct1Sampled v), bs')
else if tag == 9#32 then
let (v, bs') ← mergeMessage Chunked.EkReceivedCt1Sampled.mergeField wt (match cur with | some (.ekReceivedCt1Sampled v) => v | _ => default) bs depth; .ok (some (.ekReceivedCt1Sampled v), bs')
else if tag == 10#32 then
let (v, bs') ← mergeMessage Chunked.Ct1Acknowledged.mergeField wt (match cur with | some (.ct1Acknowledged v) => v | _ => default) bs depth; .ok (some (.ct1Acknowledged v), bs')
else if tag == 11#32 then
let (v, bs') ← mergeMessage Chunked.Ct2Sampled.mergeField wt (match cur with | some (.ct2Sampled v) => v | _ => default) bs depth; .ok (some (.ct2Sampled v), bs')
else let bs' ← skipField wt tag bs depth; .ok (cur, bs')def encode
def encode : V1State.InnerState → Bytes
| .keysUnsampled v => Proto.encodeMessage Chunked.KeysUnsampled.encodeRaw 1#32 v
| .keysSampled v => Proto.encodeMessage Chunked.KeysSampled.encodeRaw 2#32 v
| .headerSent v => Proto.encodeMessage Chunked.HeaderSent.encodeRaw 3#32 v
| .ct1Received v => Proto.encodeMessage Chunked.Ct1Received.encodeRaw 4#32 v
| .ekSentCt1Received v => Proto.encodeMessage Chunked.EkSentCt1Received.encodeRaw 5#32 v
| .noHeaderReceived v => Proto.encodeMessage Chunked.NoHeaderReceived.encodeRaw 6#32 v
| .headerReceived v => Proto.encodeMessage Chunked.HeaderReceived.encodeRaw 7#32 v
| .ct1Sampled v => Proto.encodeMessage Chunked.Ct1Sampled.encodeRaw 8#32 v
| .ekReceivedCt1Sampled v => Proto.encodeMessage Chunked.EkReceivedCt1Sampled.encodeRaw 9#32 v
| .ct1Acknowledged v => Proto.encodeMessage Chunked.Ct1Acknowledged.encodeRaw 10#32 v
| .ct2Sampled v => Proto.encodeMessage Chunked.Ct2Sampled.encodeRaw 11#32 v1 declaration not shown (lines 987–987): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
end V1State.InnerStatenamespace V1Statedef mergeField
open Proto in
def mergeField (m : V1State) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (V1State × Bytes) := do
if tag ≥ 1#32 && tag ≤ 11#32 then
let (is', bs') ← V1State.InnerState.merge m.innerState tag wt bs depth; .ok ({ m with innerState := is' }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 997–997): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def decode
def decode (bs : Bytes) : Except DecodeErr V1State := Proto.decodeTopLevelMessage mergeField bsdef encodeRaw
def encodeRaw (m : V1State) : Bytes := match m.innerState with | none => [] | some is => V1State.InnerState.encode is2 declarations not shown (lines 1000–1001): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end V1Statenamespace PqRatchetState.Innerdef merge
open Proto in
def merge (cur : Option PqRatchetState.Inner) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (Option PqRatchetState.Inner × Bytes) := do
if tag == 3#32 then
let prev := match cur with | some (.v1 v) => v | none => default
let (v, bs') ← mergeMessage V1State.mergeField wt prev bs depth; .ok (some (.v1 v), bs')
else let bs' ← skipField wt tag bs depth; .ok (cur, bs')def encode
def encode : PqRatchetState.Inner → Bytes | .v1 v => Proto.encodeMessage V1State.encodeRaw 3#32 v1 declaration not shown (lines 1013–1013): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
end PqRatchetState.Innernamespace PqRatchetStatedef mergeField
open Proto in
def mergeField (m : PqRatchetState) (tag : BitVec 32) (wt : WireType) (bs : Bytes) (depth : Nat) :
Except DecodeErr (PqRatchetState × Bytes) := do
if tag == 1#32 then
let (v, bs') ← mergeOptMessage VersionNegotiationPB.mergeField wt m.versionNegotiation bs depth
.ok ({ m with versionNegotiation := v }, bs')
else if tag == 2#32 then
let (v, bs') ← mergeOptMessage ChainPB.mergeField wt m.chain bs depth
.ok ({ m with chain := v }, bs')
else if tag == 3#32 then
let (v, bs') ← PqRatchetState.Inner.merge m.inner tag wt bs depth
.ok ({ m with inner := v }, bs')
else let bs' ← skipField wt tag bs depth; .ok (m, bs')1 declaration not shown (lines 1030–1030): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def decode
def decode (bs : Bytes) : Except DecodeErr PqRatchetState := Proto.decodeTopLevelMessage mergeField bsdef encodeRaw
def encodeRaw (m : PqRatchetState) : Bytes :=
Proto.encodeOptMessage VersionNegotiationPB.encodeRaw 1#32 m.versionNegotiation ++
Proto.encodeOptMessage ChainPB.encodeRaw 2#32 m.chain ++
match m.inner with | none => [] | some i => PqRatchetState.Inner.encode i1 declaration not shown (lines 1036–1036): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def encode
def encode (m : PqRatchetState) : Bytes := encodeRaw mend PqRatchetStatenamespace Protodef decodeState
PqRatchetState::decode (src/).
def decodeState (bs : Bytes) : Except DecodeErr PqRatchetState := PqRatchetState.decode bsdef spqrDecodeState
spqr::decode_state (src/): returns default PqRatchetState on [], and maps any decode error to Error::StateDecode.
def spqrDecodeState (bs : Bytes) : Except Error PqRatchetState :=
if bs.isEmpty then .ok { versionNegotiation := none, chain := none, inner := none }
else match PqRatchetState.decode bs with | .ok st => .ok st | .error _ => .error .stateDecodedef encodeState
PqRatchetState::encode_to_vec.
def encodeState (s : PqRatchetState) : Bytes := PqRatchetState.encode s2 declarations not shown (lines 1055–1056): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
end Proto6 declarations not shown (lines 1060–1110): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification., CryptoVerification.
end CryptoVerification.LibsignalSpqrV1