Skip to content

Commit

Permalink
add outcome to lpc marshalling, todos #73
Browse files Browse the repository at this point in the history
update marshalling for proof-producer #73

Remove r1cs marshalling tests and example, update todos for zk #73

todo merkle proof

abstract method generate_assignments #73

Leave merkle_proof as it is #73

todo in tests

reference operator=

remove dummy eq operator
  • Loading branch information
vo-nil committed Oct 15, 2024
1 parent f2f6baf commit e1625c7
Show file tree
Hide file tree
Showing 28 changed files with 49 additions and 1,660 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,18 @@ namespace nil {

/************************* Arithmetic operations ***********************************/

constexpr curve_element operator=(const curve_element &other) {
// handle special cases having to do with O
constexpr curve_element& operator=(curve_element<params_type, form, curves::coordinates::affine> const &other) {
this->X = other.X;
this->Y = other.Y;
this->T = other.T;
this->Z = other.Z;

this->T = other.X*other.Y;
this->Z = field_value_type::one();
return *this;
}

static curve_element from_affine(curve_element<params_type, form, curves::coordinates::affine> const &other) {
return curve_element(other.X, other.Y, other.X*other.Y, field_value_type::one());
}


template<typename Backend,
boost::multiprecision::expression_template_option ExpressionTemplates>
constexpr const curve_element& operator=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace nil {
// we expect that most of the operations would only use MIDDLE_OP
virtual std::map<gate_class, std::vector<constraint_type>> generate_gates(zkevm_circuit_type &zkevm_circuit) = 0;

virtual void generate_assignments(zkevm_circuit_type &zkevm_circuit, zkevm_machine_interface &machine);
virtual void generate_assignments(zkevm_circuit_type &zkevm_circuit, zkevm_machine_interface &machine) = 0;
// should return the same rows amount for everyс operation right now
// here in case we would make it dynamic in the future
virtual std::size_t rows_amount() = 0;
Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/blueprint/test/zkevm/opcodes/div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <nil/blueprint/zkevm/zkevm_circuit.hpp>
#include "../opcode_tester.hpp"

#include <nil/blueprint/zkevm/operations/mul.hpp>
#include <nil/blueprint/zkevm/operations/div.hpp>

using namespace nil::blueprint;
using namespace nil::crypto3::algebra;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ namespace nil {
namespace marshalling {
namespace processing {

// Encoding of babyjubjub curve as described in Nocturne:
// Encoding of babyjubjub curve as described in Nocturne (endianness not specified)
// https://nocturne-xyz.gitbook.io/nocturne/protocol-details/encodings
// Only Y coordinate is encoded, plus 's' - the "sign" of X coordinate
// uint256(signBit) << 254 | y
// TODO: update reference or invent our own rules
//
// Similar encoding is used here:
// https://zkkit.pse.dev/functions/_zk_kit_baby_jubjub.packPoint.html
// with implicit little-endian

template<typename Coordinates>
struct curve_element_writer<
Expand Down Expand Up @@ -132,9 +135,6 @@ namespace nil {
nil::marshalling::status_type>::type
process(group_value_type &point, TIter &iter)
{

// somehow add size check of container pointed by iter
// assert(TSize == std::distance(first, last));
using base_field_type = typename group_type::field_type;
using base_integral_type = typename base_field_type::integral_type;
using group_affine_value_type =
Expand All @@ -156,9 +156,6 @@ namespace nil {
return decoded_point_affine.error();
}

// TODO: remove hard-coded call for type conversion, implement type conversion between
// coordinates
// through operator
point = decoded_point_affine.value();
return nil::marshalling::status_type::success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#define CRYPTO3_MARSHALLING_PROCESSING_CURVE_ELEMENT_HPP

#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <limits>
#include <iterator>

#include <nil/marshalling/endianness.hpp>
#include <nil/marshalling/status_type.hpp>
Expand All @@ -46,8 +42,7 @@ namespace nil {
namespace crypto3 {
namespace marshalling {
namespace processing {
// TODO: add marshalling algorithm specification template parameter and specialize parameters depending
// on the algorithm and curve group if needed

template<typename Group>
struct curve_element_marshalling_params {
using group_type = Group;
Expand Down Expand Up @@ -78,13 +73,9 @@ namespace nil {
};


// TODO: do not specify marshalling algorithm by curve group, instead specify marshalling procedure only
// by form, coordinates and specification policy
template<typename Endianness, typename Group>
struct curve_element_writer;

// TODO: do not specify marshalling algorithm by curve group, instead specify marshalling procedure only
// by form, coordinates and specification policy
template<typename Endianness, typename Group>
struct curve_element_reader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ namespace nil {
if (compression) {
result |= C_bit;
}
// TODO: check condition of infinite point
// TODO: did not work as affine point should be fixed for zero-point
if (point.is_zero()) {
result |= I_bit;
} else if (compression && sign_gf_p<typename GroupValueType::field_type>(point.to_affine().Y)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ namespace nil {
process(group_value_type &point, TIter &iter)
{

// somehow add size check of container pointed by iter
// assert(TSize == std::distance(first, last));
using base_field_type = typename group_type::field_type;
using base_integral_type = typename base_field_type::integral_type;
using group_affine_value_type =
Expand All @@ -149,10 +147,7 @@ namespace nil {
return decoded_point_affine.error();
}

// TODO: remove hard-coded call for type conversion, implement type conversion between
// coordinates
// through operator
point = decoded_point_affine.value().to_extended_with_a_minus_1();
point = decoded_point_affine.value();
return nil::marshalling::status_type::success;
}
};
Expand Down
3 changes: 0 additions & 3 deletions crypto3/libs/marshalling/algebra/test/curve_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ void test_group_element(T val) {

using unit_type = unsigned char;

// TODO: add incorrect blobs
// TODO: add bits container checks
//
static_assert(nil::marshalling::is_compatible<T>::value);
nil::marshalling::status_type status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace nil {
TTypeBase,
// path_element_t
typename merkle_proof_path_element<TTypeBase, MerkleProof>::type,
// TODO: use nil::marshalling::option::fixed_size_storage<MerkleProof::arity - 1>
// layer
nil::marshalling::option::sequence_size_field_prefix<
nil::marshalling::types::integral<TTypeBase, std::uint64_t>>>;
};
Expand Down
4 changes: 0 additions & 4 deletions crypto3/libs/marshalling/zk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE

cm_add_test_subdirectory(test)

if(BUILD_EXAMPLES)
add_subdirectory(example)
endif()

if((CMAKE_COMPILER_IS_GNUCC) OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
set(extra_flags_list -Wall -Wextra -Wcast-align -Wcast-qual
-Wctor-dtor-privacy -Wmissing-include-dirs -Woverloaded-virtual
Expand Down
39 changes: 0 additions & 39 deletions crypto3/libs/marshalling/zk/example/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit e1625c7

Please sign in to comment.