purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
accountable.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Judica, Inc.
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or https://opensource.org/license/mit/.
4
9
10#pragma once
11
12#include <array>
13#include <span>
14
15#include "purify/numeric.hpp"
16
18
28 std::array<unsigned char, 32> signing_key{};
29 std::array<unsigned char, 32> host_commitment{};
30 std::span<const unsigned char> slot;
31};
32
34class ScalarSignature {
35public:
37 [[nodiscard]] static Result<ScalarSignature> deserialize(std::span<const unsigned char> bytes);
38
40 [[nodiscard]] std::array<unsigned char, 32> serialize() const { return scalar_.to_bytes_be(); }
41
42private:
43 explicit ScalarSignature(FieldElement scalar) : scalar_(scalar) {}
44 FieldElement scalar_;
45};
46
54 const ConflictContext& context, purify_secp_context* secp_context);
55
63 const ConflictContext& context, std::span<const unsigned char> canonical_body,
64 purify_secp_context* secp_context);
65
74 const ConflictContext& context, std::span<const unsigned char> canonical_body,
75 const ScalarSignature& signature, purify_secp_context* secp_context);
76
91 const ConflictContext& context,
92 std::span<const unsigned char> first_body, const ScalarSignature& first_signature,
93 std::span<const unsigned char> second_body, const ScalarSignature& second_signature,
94 purify_secp_context* secp_context);
95
96} // namespace purify::accountable
Field element modulo the backend scalar field used by this implementation.
Definition numeric.hpp:815
Canonical 32-byte scalar response; carries no nonce or proof.
static Result< ScalarSignature > deserialize(std::span< const unsigned char > bytes)
Parse exactly 32 big-endian bytes below the group order, including zero.
std::array< unsigned char, 32 > serialize() const
Return the complete scalar-only wire representation.
Result< std::array< unsigned char, 33 > > reconstruct_nonce(const ConflictContext &context, std::span< const unsigned char > canonical_body, const ScalarSignature &signature, purify_secp_context *secp_context)
Reconstruct the full nonce point as sigma*G - e*Q, rejecting infinity.
Result< std::array< unsigned char, 32 > > nonce_evaluation_input(const ConflictContext &context, purify_secp_context *secp_context)
Derive the candidate deterministic Purify input from the registered slot.
Result< FieldElement > signature_challenge(const ConflictContext &context, std::span< const unsigned char > canonical_body, purify_secp_context *secp_context)
Compute the versioned Q/U/T/body challenge, without a nonce point.
Result< std::array< unsigned char, 32 > > recover_same_slot_key(const ConflictContext &context, std::span< const unsigned char > first_body, const ScalarSignature &first_signature, std::span< const unsigned char > second_body, const ScalarSignature &second_signature, purify_secp_context *secp_context)
Recover the exact signing scalar exposed by two same-slot responses.
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Definition error.hpp:99
Fixed-width integer and field arithmetic helpers used throughout Purify.
Public context shared by conflicting statements in one slashable slot.
std::array< unsigned char, 32 > host_commitment
std::span< const unsigned char > slot
std::array< unsigned char, 32 > signing_key