From 29fd5e22d9ba135561dc556af3250e3991efe3ee Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Thu, 2 Jul 2026 21:46:25 -0500 Subject: [PATCH] Use zat signCommit for repo commits --- build.zig.zon | 4 ++-- src/storage/store.zig | 26 +++++++++----------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index b6c64cc..5589045 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,8 +5,8 @@ .minimum_zig_version = "0.16.0", .dependencies = .{ .zat = .{ - .url = "https://tangled.org/zat.dev/zat/archive/v0.3.9.tar.gz", - .hash = "zat-0.3.9-5PuC7v6aCgDbfEdNEUxbSbbpq27V5upmAsa6J-kqdCXx", + .url = "https://tangled.org/zat.dev/zat/archive/v0.3.10.tar.gz", + .hash = "zat-0.3.10-5PuC7rnoCgBcN3vEheCoTrbqOeLkGe8TuNpnP2jypNP6", }, .zqlite = .{ .url = "git+https://github.com/karlseguin/zqlite.zig?ref=master#05a88d6758753e1c63fdd45b211dde2057094b0c", diff --git a/src/storage/store.zig b/src/storage/store.zig index 7360d60..5d6ca01 100644 --- a/src/storage/store.zig +++ b/src/storage/store.zig @@ -4766,24 +4766,16 @@ fn signedCommitWithKeypair( prev_cid_raw: ?[]const u8, keypair: *const zat.Keypair, ) !SignedCommit { - var unsigned_entries = try allocator.alloc(zat.cbor.Value.MapEntry, 5); - unsigned_entries[0] = .{ .key = "did", .value = .{ .text = did } }; - unsigned_entries[1] = .{ .key = "version", .value = .{ .unsigned = 3 } }; - unsigned_entries[2] = .{ .key = "data", .value = .{ .cid = data_cid } }; - unsigned_entries[3] = .{ .key = "rev", .value = .{ .text = rev } }; - unsigned_entries[4] = .{ .key = "prev", .value = if (prev_cid_raw) |raw| .{ .cid = .{ .raw = raw } } else .null }; - const unsigned_value: zat.cbor.Value = .{ .map = unsigned_entries }; - const unsigned_bytes = try zat.cbor.encodeAlloc(allocator, unsigned_value); - const sig = try keypair.sign(unsigned_bytes); - - var signed_entries = try allocator.alloc(zat.cbor.Value.MapEntry, 6); - @memcpy(signed_entries[0..5], unsigned_entries); - signed_entries[5] = .{ .key = "sig", .value = .{ .bytes = &sig.bytes } }; - const signed_bytes = try zat.cbor.encodeAlloc(allocator, .{ .map = signed_entries }); - const commit_cid = try zat.cbor.Cid.forDagCbor(allocator, signed_bytes); + const signed = try zat.signCommit(allocator, .{ + .did = did, + .rev = rev, + .data = data_cid, + .prev = if (prev_cid_raw) |raw| .{ .raw = raw } else null, + }, keypair); + defer allocator.free(signed.cid.raw); return .{ - .cid = try cidText(allocator, commit_cid.raw), - .data = signed_bytes, + .cid = try cidText(allocator, signed.cid.raw), + .data = signed.bytes, }; } -- 2.51.2