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"
17
18namespace purify::accountable {
19
30 std::array<unsigned char, 32> signing_key{};
31 std::array<unsigned char, 32> host_commitment{};
33 std::span<const unsigned char> slot;
34};
35
37class ScalarSignature {
38public:
40 [[nodiscard]] static Result<ScalarSignature> deserialize(std::span<const unsigned char> bytes);
41
43 [[nodiscard]] std::array<unsigned char, 32> serialize() const { return scalar_.to_bytes_be(); }
44
45private:
46 explicit ScalarSignature(FieldElement scalar) : scalar_(scalar) {}
47 FieldElement scalar_;
48};
49
58 const ConflictContext& context, purify_secp_context* secp_context);
59
67 const ConflictContext& context, std::span<const unsigned char> canonical_body,
68 purify_secp_context* secp_context);
69
78 const ConflictContext& context, std::span<const unsigned char> canonical_body,
79 const ScalarSignature& signature, purify_secp_context* secp_context);
80
95 const ConflictContext& context,
96 std::span<const unsigned char> first_body, const ScalarSignature& first_signature,
97 std::span<const unsigned char> second_body, const ScalarSignature& second_signature,
98 purify_secp_context* secp_context);
99
100} // namespace purify::accountable
Field element modulo the backend scalar field used by this implementation.
Definition numeric.hpp:834
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.
One-shot Bitcoin bindings for accountable coalition formation.
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.
std::array< unsigned char, 32 > CoalitionCoreDigest
Result< FieldElement > signature_challenge(const ConflictContext &context, std::span< const unsigned char > canonical_body, purify_secp_context *secp_context)
Compute the versioned Q/U/core/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
CoalitionCoreDigest coalition_core_digest