Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COSE signatures over merkle root in the ledger #6453

Merged
merged 36 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
937c621
WIP
maxtropets Aug 27, 2024
e3a71ad
Cose signature simplified. Check tests
maxtropets Aug 28, 2024
f5da99b
Key fixup
maxtropets Aug 28, 2024
400bba6
Support variable COSE header types
maxtropets Aug 29, 2024
f51b3b1
Sign VDS + txid
maxtropets Aug 29, 2024
14818e7
Change node key to service key for COSE
maxtropets Aug 29, 2024
2bed88b
Change key setting in history
maxtropets Aug 30, 2024
baabe3d
Doc rst WIP
maxtropets Aug 30, 2024
35bacc0
Fixup keys in tests
maxtropets Aug 30, 2024
6de9314
Fixup change deser
maxtropets Aug 30, 2024
49537db
Verify COSE in history->verify
maxtropets Sep 5, 2024
d89b7c5
Format checks
maxtropets Sep 5, 2024
246e3d5
Optimise key creation
maxtropets Sep 5, 2024
ec538fa
Rollback public key caching
maxtropets Sep 6, 2024
c046403
FIx history test (mock service key)
maxtropets Sep 6, 2024
ec59604
Merge branch 'main' into f/cose-sign-merkle-root
maxtropets Sep 6, 2024
7ef7f27
Change default curve to es384
maxtropets Sep 10, 2024
5272c14
Add cose sig verification to python ledger checker
maxtropets Sep 10, 2024
69fa97d
Fix linter
maxtropets Sep 10, 2024
45ec618
Use correct alg id in signing
maxtropets Sep 10, 2024
1055180
Cache verifier
maxtropets Sep 10, 2024
cbd46f2
Improve alg. verification in cpp code
maxtropets Sep 10, 2024
08a800c
Format fix
maxtropets Sep 10, 2024
d35115e
Pass kid as key hash
maxtropets Sep 10, 2024
34f21f3
Update doc
maxtropets Sep 10, 2024
d3dcf18
Merge branch 'main' into f/cose-sign-merkle-root
maxtropets Sep 10, 2024
270a646
Redundant spaces
maxtropets Sep 10, 2024
63a30b4
Long test (removeme)
maxtropets Sep 10, 2024
3b9f986
Typos and logs
maxtropets Sep 11, 2024
bd94818
FIx ASAN
maxtropets Sep 11, 2024
da541bb
Remove SECP256K1 support
maxtropets Sep 11, 2024
77c11dc
COSE sig as bytes instead of JSON(bytes)
maxtropets Sep 11, 2024
bb3adc1
Improved estimated arg size
maxtropets Sep 11, 2024
c00f963
Merge branch 'main' into f/cose-sign-merkle-root
maxtropets Sep 11, 2024
a668cf8
Revert "Long test (removeme)"
maxtropets Sep 11, 2024
e90e33f
Cose as JSON in python parser
maxtropets Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/src/ccf/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,7 @@ def add_transaction(self, transaction):
if COSE_SIGNATURE_TX_TABLE_NAME in tables:
cose_signature_table = tables[COSE_SIGNATURE_TX_TABLE_NAME]
cose_signature = cose_signature_table.get(WELL_KNOWN_SINGLETON_TABLE_KEY)
signature = json.loads(cose_signature)
cose_sign1 = base64.b64decode(signature["sig"])
cose_sign1 = base64.b64decode(cose_signature)
maxtropets marked this conversation as resolved.
Show resolved Hide resolved
self._verify_root_cose_signature(self.merkle.get_merkle_root(), cose_sign1)

# Checks complete, add this transaction to tree
Expand Down
4 changes: 2 additions & 2 deletions src/node/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace ccf
auto cose_sign = crypto::cose_sign1(service_kp, pheaders, root_hash);

signatures->put(sig_value);
cose_signatures->put(CoseSignature{cose_sign});
cose_signatures->put(cose_sign);
serialised_tree->put(history.serialise_tree(txid.version - 1));
return sig.commit_reserved();
}
Expand Down Expand Up @@ -764,7 +764,7 @@ namespace ccf
root.h.data(), root.h.data() + root.h.size()};

return cose_verifier_cached(raw_cert)->verify_detached(
cose_sig->sig, root_hash);
cose_sig.value(), root_hash);
}

std::vector<uint8_t> serialise_tree(size_t to) override
Expand Down
12 changes: 1 addition & 11 deletions src/service/tables/signatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,7 @@ namespace ccf
using SerialisedMerkleTree =
ccf::kv::RawCopySerialisedValue<std::vector<uint8_t>>;

struct CoseSignature
{
std::vector<uint8_t> sig;

CoseSignature() {}

CoseSignature(const std::vector<uint8_t>& sig_) : sig(sig_) {}
};

DECLARE_JSON_TYPE(CoseSignature)
DECLARE_JSON_REQUIRED_FIELDS(CoseSignature, sig);
using CoseSignature = std::vector<uint8_t>;

// Most recent COSE signature is a single Value in the KV
using CoseSignatures = ServiceValue<CoseSignature>;
Expand Down
Loading