purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
sha256_transcript.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
5#pragma once
6
7#include <array>
8#include <cstdint>
9#include <span>
10
11#include "purify/common.hpp"
12#include "purify/numeric.hpp"
13
15
16using TranscriptBytes32 = std::array<unsigned char, 32>;
18
27
39public:
41
42 void append_field(const TranscriptBytes32& value);
43 void append_scalar(const FieldElement& value);
44 [[nodiscard]] Status append_point(unsigned char prefix,
45 const TranscriptBytes32& x);
46 [[nodiscard]] Status append_point_pair(unsigned char parity,
47 const TranscriptBytes32& first_x,
48 const TranscriptBytes32& second_x);
49 [[nodiscard]] Status append_bytes(std::span<const unsigned char> bytes);
50 void append_u64(std::uint64_t value);
51
53 [[nodiscard]] Result<Sha256Challenge> challenge(std::uint64_t round);
54
60 [[nodiscard]] Result<Sha256Challenge>
61 opening_base_scalar(const TranscriptDigest& basis_digest,
62 std::uint64_t role) const;
63
64private:
65 void append_header(std::uint32_t item_type, std::uint64_t auxiliary);
66 void append_payload(std::span<const unsigned char> payload);
67
68 TranscriptDigest state_{};
69 Bytes pending_;
70};
71
72} // namespace purify::bppp::candidate
Field element modulo the backend scalar field used by this implementation.
Definition numeric.hpp:834
void append_scalar(const FieldElement &value)
Result< Sha256Challenge > challenge(std::uint64_t round)
Status append_point(unsigned char prefix, const TranscriptBytes32 &x)
Status append_bytes(std::span< const unsigned char > bytes)
void append_field(const TranscriptBytes32 &value)
Status append_point_pair(unsigned char parity, const TranscriptBytes32 &first_x, const TranscriptBytes32 &second_x)
Result< Sha256Challenge > opening_base_scalar(const TranscriptDigest &basis_digest, std::uint64_t role) const
Shared includes and foundational aliases for the Purify C++ implementation.
std::array< unsigned char, 32 > TranscriptBytes32
TranscriptBytes32 TranscriptDigest
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Definition error.hpp:99
Expected< void, Error > Status
Expected-returning convenience alias for Purify status-only APIs.
Definition error.hpp:102
std::vector< unsigned char > Bytes
Dynamically sized byte string used for messages, serialized witnesses, and proofs.
Definition common.hpp:99
Fixed-width integer and field arithmetic helpers used throughout Purify.
friend bool operator==(const Sha256Challenge &, const Sha256Challenge &)=default