Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Komodo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Show more breadcrumbs
Dragoon
Komodo
Commits
cbb2e6de
Unverified
Commit
cbb2e6de
authored
1 year ago
by
STEVAN Antoine
Browse files
Options
Downloads
Patches
Plain Diff
use curve templates in the FEC tests
parent
1b59e43b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3750
passed
1 year ago
Stage: fmt
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fec.rs
+31
-27
31 additions, 27 deletions
src/fec.rs
with
31 additions
and
27 deletions
src/fec.rs
+
31
−
27
View file @
cbb2e6de
...
@@ -154,12 +154,7 @@ mod tests {
...
@@ -154,12 +154,7 @@ mod tests {
];
];
const
LOST_SHARDS
:
[
usize
;
3
]
=
[
1
,
3
,
6
];
const
LOST_SHARDS
:
[
usize
;
3
]
=
[
1
,
3
,
6
];
fn
to_big_int_from_bytes
(
i
:
&
[
u8
])
->
<
Bls12_381
as
Pairing
>
::
ScalarField
{
fn
decoding_template
<
E
:
Pairing
>
()
{
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
i
)
}
#[test]
fn
decoding
()
{
let
hash
=
Sha256
::
hash
(
DATA
)
.to_vec
();
let
hash
=
Sha256
::
hash
(
DATA
)
.to_vec
();
let
mut
shards
=
SHARDS
let
mut
shards
=
SHARDS
...
@@ -167,7 +162,7 @@ mod tests {
...
@@ -167,7 +162,7 @@ mod tests {
.map
(|
r
|
{
.map
(|
r
|
{
Some
(
Some
(
r
.iter
()
r
.iter
()
.map
(|
s
|
to_big_int_
from_bytes
(
&
s
.to_le_bytes
()))
.map
(|
s
|
E
::
ScalarField
::
from_
le_
bytes
_mod_order
(
&
s
.to_le_bytes
()))
.collect
::
<
Vec
<
_
>>
(),
.collect
::
<
Vec
<
_
>>
(),
)
)
})
})
...
@@ -183,16 +178,21 @@ mod tests {
...
@@ -183,16 +178,21 @@ mod tests {
k
:
K
as
u32
,
k
:
K
as
u32
,
linear_combination
:
vec!
[
LinearCombinationElement
{
linear_combination
:
vec!
[
LinearCombinationElement
{
index
:
i
as
u32
,
index
:
i
as
u32
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
one
(),
weight
:
E
::
ScalarField
::
one
(),
}],
}],
hash
:
hash
.clone
(),
hash
:
hash
.clone
(),
bytes
:
field
::
merge_elements_into_bytes
::
<
Bls12_381
>
(
bytes
),
bytes
:
field
::
merge_elements_into_bytes
::
<
E
>
(
bytes
),
size
:
DATA
.len
(),
size
:
DATA
.len
(),
});
});
}
}
}
}
assert_eq!
(
DATA
,
decode
::
<
GF
,
Bls12_381
>
(
blocks
)
.unwrap
())
assert_eq!
(
DATA
,
decode
::
<
GF
,
E
>
(
blocks
)
.unwrap
())
}
#[test]
fn
decoding
()
{
decoding_template
::
<
Bls12_381
>
();
}
}
fn
create_fake_shard
<
E
:
Pairing
>
(
fn
create_fake_shard
<
E
:
Pairing
>
(
...
@@ -211,38 +211,37 @@ mod tests {
...
@@ -211,38 +211,37 @@ mod tests {
}
}
}
}
#[test]
fn
recoding_template
<
E
:
Pairing
>
()
{
fn
recoding
()
{
let
a
:
Shard
<
E
>
=
create_fake_shard
(
let
a
:
Shard
<
Bls12_381
>
=
create_fake_shard
(
&
[
LinearCombinationElement
{
&
[
LinearCombinationElement
{
index
:
0
,
index
:
0
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
one
(),
weight
:
E
::
ScalarField
::
one
(),
}],
}],
&
[
1
,
2
,
3
],
&
[
1
,
2
,
3
],
);
);
let
b
:
Shard
<
Bls12_381
>
=
create_fake_shard
(
let
b
:
Shard
<
E
>
=
create_fake_shard
(
&
[
LinearCombinationElement
{
&
[
LinearCombinationElement
{
index
:
1
,
index
:
1
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
one
(),
weight
:
E
::
ScalarField
::
one
(),
}],
}],
&
[
4
,
5
,
6
],
&
[
4
,
5
,
6
],
);
);
assert_eq!
(
assert_eq!
(
a
.mul
(
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
])),
a
.mul
(
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
])),
create_fake_shard
(
create_fake_shard
(
&
[
LinearCombinationElement
{
&
[
LinearCombinationElement
{
index
:
0
,
index
:
0
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
]),
}],
}],
&
[
2
,
4
,
6
],
&
[
2
,
4
,
6
],
)
)
);
);
let
c
=
a
.combine
(
let
c
=
a
.combine
(
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
3
]),
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
3
]),
&
b
,
&
b
,
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
5
]),
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
5
]),
);
);
assert_eq!
(
assert_eq!
(
...
@@ -251,11 +250,11 @@ mod tests {
...
@@ -251,11 +250,11 @@ mod tests {
&
[
&
[
LinearCombinationElement
{
LinearCombinationElement
{
index
:
0
,
index
:
0
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
3
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
3
]),
},
},
LinearCombinationElement
{
LinearCombinationElement
{
index
:
1
,
index
:
1
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
5
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
5
]),
}
}
],
],
&
[
23
,
31
,
39
]
&
[
23
,
31
,
39
]
...
@@ -264,27 +263,32 @@ mod tests {
...
@@ -264,27 +263,32 @@ mod tests {
assert_eq!
(
assert_eq!
(
c
.combine
(
c
.combine
(
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
]),
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
2
]),
&
a
,
&
a
,
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
4
]),
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
4
]),
),
),
create_fake_shard
(
create_fake_shard
(
&
[
&
[
LinearCombinationElement
{
LinearCombinationElement
{
index
:
0
,
index
:
0
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
6
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
6
]),
},
},
LinearCombinationElement
{
LinearCombinationElement
{
index
:
1
,
index
:
1
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
10
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
10
]),
},
},
LinearCombinationElement
{
LinearCombinationElement
{
index
:
0
,
index
:
0
,
weight
:
<
Bls12_381
as
Pairing
>
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
4
]),
weight
:
E
::
ScalarField
::
from_le_bytes_mod_order
(
&
[
4
]),
}
}
],
],
&
[
50
,
70
,
90
],
&
[
50
,
70
,
90
],
)
)
);
);
}
}
#[test]
fn
recoding
()
{
recoding_template
::
<
Bls12_381
>
();
}
}
}
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