Supply Chain Integrity, Transparency, and Trust (IETF SCITT)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix merlint E331/E340 in scitt_atp: rename make_repo_key, extract error helpers

+11 -9
+11 -9
lib/atp/scitt_atp.ml
··· 33 33 | [ _algo; hex ] -> hex 34 34 | _ -> Ohex.encode subject 35 35 36 - let make_repo_key subject = 36 + let repo_key subject = 37 37 let rkey = subject_to_rkey subject in 38 38 collection ^ "/" ^ rkey 39 39 ··· 108 108 The proof is a sparse tree containing only the nodes traversed during 109 109 the key lookup. Blinded subtrees are replaced by their CID. The 110 110 serialized proof goes in the receipt's [vdp] (396) unprotected header, 111 - enabling fully offline verification via 112 - [Irmin.Private.Proof.Mst.verify]. *) 111 + enabling fully offline verification via [Irmin.Proof.Mst.verify]. *) 113 112 let compute_proof t ~key repo_key = 114 113 let root_cid = Atp.Mst.to_cid t.mst ~store:C.store in 115 114 let leaf_hash = ··· 119 118 in 120 119 (* Produce an Irmin proof for the MST lookup *) 121 120 let irmin_proof, _found = 122 - Irmin.Private.Proof.Mst.produce irmin root_cid (fun tree -> 123 - let v = Irmin.Private.Proof.Mst.Tree.find tree [ repo_key ] in 121 + Irmin.Proof.Mst.produce irmin root_cid (fun tree -> 122 + let v = Irmin.Proof.Mst.Tree.find tree [ repo_key ] in 124 123 (tree, v)) 125 124 in 126 125 (* Serialize: [repo_key, irmin_proof_cbor] packed as CBOR array. 127 126 The verifier needs the repo_key to replay the exact lookup. *) 128 127 let irmin_proof_cbor = 129 - Irmin.Private.Proof.encode_cbor ~encode_hash:Atp.Cid.to_raw_bytes 128 + Irmin.Proof.encode_cbor ~encode_hash:Atp.Cid.to_raw_bytes 130 129 ~encode_contents:Fun.id irmin_proof 131 130 in 132 131 let vdp = ··· 142 141 leaf_hash; 143 142 } 144 143 144 + let err_duplicate key = Error ("duplicate key: " ^ key) 145 + let err_encoding e = Error ("encoding error: " ^ e) 146 + 145 147 let append t ~key ~value = 146 - if Hashtbl.mem t.values key then Error (Fmt.str "duplicate key: %s" key) 148 + if Hashtbl.mem t.values key then err_duplicate key 147 149 else 148 - let repo_key = make_repo_key key in 150 + let repo_key = repo_key key in 149 151 match value_to_cid ~key value with 150 - | Error e -> Error (Fmt.str "encoding error: %s" e) 152 + | Error e -> err_encoding e 151 153 | Ok cid -> 152 154 Hashtbl.replace t.values key value; 153 155 t.mst <- Atp.Mst.add repo_key cid t.mst ~store:C.store;