ProtoPB.lean
Declarations on this page (12)
SPQR V1: shared pq_ratchet. message structures
Trusted in part. The theorems of Computational/ use every definition in this file except ChainParams., ChainParams. and the Inhabited ChainParams instance built from default, which are checked by Lean (see Computational/).
Defines the pq_ratchet. structures shared across Chain.lean, Auth.lean, and Proto.lean: symmetric-chain parameters (ChainParams, DEFAULT_CHAIN_PARAMS, ChainParamsPB, intoPb, maxJumpOrDefault, maxOooKeysOrDefault, trimSize), serialized chain epochs (EpochDirectionPB, ChainEpochPB, ChainPB), version negotiation (VersionNegotiationPB), and authenticator state (ProtoAuthenticator). Kept free of CryptoGames imports so Proto.lean stays within the symbolic statement dependency boundary.
@[expose] public sectionnamespace CryptoVerification.LibsignalSpqrV1
ChainParams and pqrpb::ChainParams (src/)
structure ChainParamsPB
Protobuf symmetric-chain parameters (pqrpb::ChainParams, where 0 encodes the default).
structure ChainParamsPB where
maxJump : BitVec 32 := 0#32
maxOooKeys : BitVec 32 := 0#32
deriving DecidableEq, Repr, Inhabitedstructure ChainParams
Symmetric-chain limits (src/): maximum forward counter jump maxJump and maximum retained out-of-order message keys maxOooKeys.
structure ChainParams where
maxJump : BitVec 32 := 25000#32
maxOooKeys : BitVec 32 := 2000#32
deriving DecidableEq, Reprdef DEFAULT_CHAIN_PARAMS
Default symmetric-chain parameters (maxJump = 25000, maxOooKeys = 2000).
def DEFAULT_CHAIN_PARAMS : ChainParams :=
{ maxJump := 25000#32, maxOooKeys := 2000#32 }namespace ChainParams1 declaration not shown (lines 54–54): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
def intoPb
Converts ChainParams to ChainParamsPB, mapping default field values to 0.
def intoPb (self : ChainParams) : ChainParamsPB :=
{ maxJump :=
if self.maxJump == DEFAULT_CHAIN_PARAMS.maxJump then 0#32 else self.maxJump
maxOooKeys :=
if self.maxOooKeys == DEFAULT_CHAIN_PARAMS.maxOooKeys then 0#32 else self.maxOooKeys }1 declaration not shown (lines 63–64): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification.
end ChainParamsnamespace ChainParamsPBdef maxJumpOrDefault
def maxJumpOrDefault (self : ChainParamsPB) : BitVec 32 :=
if self.maxJump > 0#32 then self.maxJump else DEFAULT_CHAIN_PARAMS.maxJumpdef maxOooKeysOrDefault
def maxOooKeysOrDefault (self : ChainParamsPB) : BitVec 32 :=
if self.maxOooKeys > 0#32 then self.maxOooKeys else DEFAULT_CHAIN_PARAMS.maxOooKeysdef trimSize
Out-of-order key history threshold maxOoo * 11 / 10 + 1 (src/).
def trimSize (self : ChainParamsPB) : Nat :=
let maxOoo := self.maxOooKeysOrDefault.toNat
maxOoo * 11 / 10 + 1end ChainParamsPBstructure EpochDirectionPB
pqrpb::chain::epoch::EpochDirection (src/).
structure ChainEpochPB
pqrpb::chain::Epoch (src/).
structure ChainEpochPB where
send : Option EpochDirectionPB := none
recv : Option EpochDirectionPB := none
deriving DecidableEq, Repr, Inhabitedstructure ChainPB
pqrpb::Chain (src/).
structure ChainPB where
direction : BitVec 32 := 0#32
currentEpoch : Epoch := 0#64
links : List ChainEpochPB := []
nextRoot : Bytes := []
sendEpoch : Epoch := 0#64
params : Option ChainParamsPB := none
deriving DecidableEq, Repr, Inhabitedstructure VersionNegotiationPB
pqrpb::pq_ratchet_state::VersionNegotiation (src/).
structure VersionNegotiationPB where
authKey : Bytes := []
direction : BitVec 32 := 0#32
minVersion : BitVec 32 := 0#32
chainParams : Option ChainParamsPB := none
deriving DecidableEq, Repr, Inhabitedstructure ProtoAuthenticator
pqrpb::Authenticator (src/).
end CryptoVerification.LibsignalSpqrV1