Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Polynomial Commitment -- arkworks-rs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
STEVAN Antoine
Polynomial Commitment -- arkworks-rs
Commits
575c7658
Unverified
Commit
575c7658
authored
4 years ago
by
Weikeng Chen
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Derive the serialization for `LabeledPolynomial` directly (#67)
* Update data_structures.rs * Update data_structures.rs
parent
aa27673d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/data_structures.rs
+1
-95
1 addition, 95 deletions
src/data_structures.rs
with
1 addition
and
95 deletions
src/data_structures.rs
+
1
−
95
View file @
575c7658
...
...
@@ -6,7 +6,6 @@ use ark_std::{
io
::{
Read
,
Write
},
marker
::
PhantomData
,
ops
::{
AddAssign
,
MulAssign
,
SubAssign
},
string
::
ToString
,
};
use
rand_core
::
RngCore
;
...
...
@@ -115,7 +114,7 @@ pub struct BatchLCProof<F: Field, P: Polynomial<F>, PC: PolynomialCommitment<F,
/// A polynomial along with information about its degree bound (if any), and the
/// maximum number of queries that will be made to it. This latter number determines
/// the amount of protection that will be provided to a commitment for this polynomial.
#[derive(Debug,
Clone)]
#[derive(Debug,
Clone
,
CanonicalSerialize,
CanonicalDeserialize
)]
pub
struct
LabeledPolynomial
<
F
:
Field
,
P
:
Polynomial
<
F
>>
{
label
:
PolynomialLabel
,
polynomial
:
Rc
<
P
>
,
...
...
@@ -124,99 +123,6 @@ pub struct LabeledPolynomial<F: Field, P: Polynomial<F>> {
_field
:
PhantomData
<
F
>
,
}
impl
<
F
:
Field
,
P
:
Polynomial
<
F
>>
CanonicalSerialize
for
LabeledPolynomial
<
F
,
P
>
{
fn
serialize
<
W
:
Write
>
(
&
self
,
mut
writer
:
W
)
->
Result
<
(),
SerializationError
>
{
self
.label
.clone
()
.into_bytes
()
.serialize
(
&
mut
writer
)
?
;
self
.polynomial
.serialize
(
&
mut
writer
)
?
;
self
.degree_bound
.serialize
(
&
mut
writer
)
?
;
self
.hiding_bound
.serialize
(
&
mut
writer
)
}
fn
serialized_size
(
&
self
)
->
usize
{
self
.label
.clone
()
.into_bytes
()
.serialized_size
()
+
self
.polynomial
.serialized_size
()
+
self
.degree_bound
.serialized_size
()
+
self
.hiding_bound
.serialized_size
()
}
fn
serialize_uncompressed
<
W
:
Write
>
(
&
self
,
mut
writer
:
W
)
->
Result
<
(),
SerializationError
>
{
self
.label
.clone
()
.into_bytes
()
.serialize_uncompressed
(
&
mut
writer
)
?
;
self
.polynomial
.serialize_uncompressed
(
&
mut
writer
)
?
;
self
.degree_bound
.serialize_uncompressed
(
&
mut
writer
)
?
;
self
.hiding_bound
.serialize_uncompressed
(
&
mut
writer
)
}
fn
serialize_unchecked
<
W
:
Write
>
(
&
self
,
mut
writer
:
W
)
->
Result
<
(),
SerializationError
>
{
self
.label
.clone
()
.into_bytes
()
.serialize_unchecked
(
&
mut
writer
)
?
;
self
.polynomial
.serialize_unchecked
(
&
mut
writer
)
?
;
self
.degree_bound
.serialize_unchecked
(
&
mut
writer
)
?
;
self
.hiding_bound
.serialize_unchecked
(
&
mut
writer
)
}
fn
uncompressed_size
(
&
self
)
->
usize
{
self
.label
.clone
()
.into_bytes
()
.uncompressed_size
()
+
self
.polynomial
.uncompressed_size
()
+
self
.degree_bound
.uncompressed_size
()
+
self
.hiding_bound
.uncompressed_size
()
}
}
impl
<
F
:
Field
,
P
:
Polynomial
<
F
>>
CanonicalDeserialize
for
LabeledPolynomial
<
F
,
P
>
{
fn
deserialize
<
R
:
Read
>
(
mut
reader
:
R
)
->
Result
<
Self
,
SerializationError
>
{
let
label_bytes
=
Vec
::
<
u8
>
::
deserialize
(
&
mut
reader
)
?
;
let
label
=
String
::
from_utf8_lossy
(
&
label_bytes
);
let
polynomial
=
Rc
::
new
(
P
::
deserialize
(
&
mut
reader
)
?
);
let
degree_bound
=
Option
::
<
usize
>
::
deserialize
(
&
mut
reader
)
?
;
let
hiding_bound
=
Option
::
<
usize
>
::
deserialize
(
&
mut
reader
)
?
;
Ok
(
Self
{
label
:
label
.to_string
(),
polynomial
,
degree_bound
,
hiding_bound
,
_field
:
PhantomData
,
})
}
fn
deserialize_uncompressed
<
R
:
Read
>
(
mut
reader
:
R
)
->
Result
<
Self
,
SerializationError
>
{
let
label_bytes
=
Vec
::
<
u8
>
::
deserialize_uncompressed
(
&
mut
reader
)
?
;
let
label
=
String
::
from_utf8_lossy
(
&
label_bytes
);
let
polynomial
=
Rc
::
new
(
P
::
deserialize_uncompressed
(
&
mut
reader
)
?
);
let
degree_bound
=
Option
::
<
usize
>
::
deserialize_uncompressed
(
&
mut
reader
)
?
;
let
hiding_bound
=
Option
::
<
usize
>
::
deserialize_uncompressed
(
&
mut
reader
)
?
;
Ok
(
Self
{
label
:
label
.to_string
(),
polynomial
,
degree_bound
,
hiding_bound
,
_field
:
PhantomData
,
})
}
fn
deserialize_unchecked
<
R
:
Read
>
(
mut
reader
:
R
)
->
Result
<
Self
,
SerializationError
>
{
let
label_bytes
=
Vec
::
<
u8
>
::
deserialize_unchecked
(
&
mut
reader
)
?
;
let
label
=
String
::
from_utf8_lossy
(
&
label_bytes
);
let
polynomial
=
Rc
::
new
(
P
::
deserialize_unchecked
(
&
mut
reader
)
?
);
let
degree_bound
=
Option
::
<
usize
>
::
deserialize_unchecked
(
&
mut
reader
)
?
;
let
hiding_bound
=
Option
::
<
usize
>
::
deserialize_unchecked
(
&
mut
reader
)
?
;
Ok
(
Self
{
label
:
label
.to_string
(),
polynomial
,
degree_bound
,
hiding_bound
,
_field
:
PhantomData
,
})
}
}
impl
<
'a
,
F
:
Field
,
P
:
Polynomial
<
F
>>
core
::
ops
::
Deref
for
LabeledPolynomial
<
F
,
P
>
{
type
Target
=
P
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment