objective categorical abstract machine language personal data server
65
fork

Configure Feed

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

Simplify signing data

futurGH 5628b0b4 af31e228

+8 -22
+4
kleidos/kleidos.ml
··· 208 208 209 209 let parse_multikey_str multikey : key = 210 210 multikey |> bytes_of_multikey |> parse_multikey_bytes 211 + 212 + let sign ~privkey ~msg : bytes = 213 + let privkey, (module Curve : CURVE) = privkey in 214 + Curve.sign ~privkey ~msg
+1 -2
pegasus/lib/plc.ml
··· 171 171 type audit_log = audit_log_entry list [@@deriving yojson {strict= false}] 172 172 173 173 let sign_operation (key : Kleidos.key) operation : signed_operation = 174 - let sig_privkey, (module Sig_curve) = key in 175 174 let cbor = unsigned_operation_to_yojson operation |> Dag_cbor.encode_yojson in 176 - let sig_bytes = Sig_curve.sign ~privkey:sig_privkey ~msg:cbor in 175 + let sig_bytes = Kleidos.sign ~privkey:key ~msg:cbor in 177 176 let sig_str = 178 177 Result.get_ok @@ Multibase.encode_t `Base64url (Bytes.to_string sig_bytes) 179 178 in
+3 -20
pegasus/lib/repository.ml
··· 14 14 let delete = "com.atproto.repo.applyWrites#delete" 15 15 end 16 16 17 - type signing_key = P256 of bytes | K256 of bytes 18 - 19 17 type repo_write = 20 18 | Create of 21 19 { type': string [@key "$type"] [@default Write_op.create] ··· 139 137 {commit: Cid.t * signed_commit; results: apply_writes_result list} 140 138 141 139 type t = 142 - { key: signing_key 140 + { key: Kleidos.key 143 141 ; did: string 144 142 ; db: User_store.t 145 143 ; mutable block_map: Cid.t StringMap.t option ··· 196 194 [] 197 195 198 196 let sign_commit t commit : signed_commit = 199 - let sign_fn, privkey = 200 - match t.key with 201 - | K256 k -> 202 - (Kleidos.K256.sign, k) 203 - | P256 k -> 204 - (Kleidos.P256.sign, k) 205 - in 206 197 let msg = commit |> commit_to_yojson |> Dag_cbor.encode_yojson in 207 - let signature = sign_fn ~privkey ~msg in 198 + let signature = Kleidos.sign ~privkey:t.key ~msg in 208 199 { did= commit.did 209 200 ; version= commit.version 210 201 ; data= commit.data ··· 446 437 | None -> 447 438 failwith ("failed to retrieve actor for " ^ did) 448 439 in 449 - let key = 450 - match Kleidos.parse_multikey_str signing_key with 451 - | key, (module M) when M.name = "K256" -> 452 - K256 key 453 - | key, (module M) when M.name = "P256" -> 454 - P256 key 455 - | _ -> 456 - failwith "unsupported key type" 457 - in 440 + let key = Kleidos.parse_multikey_str signing_key in 458 441 let%lwt commit = 459 442 match%lwt User_store.get_commit user_db with 460 443 | Some (cid, _) ->