Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mental Poker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
William KOCH
Mental Poker
Commits
ea666df1
Commit
ea666df1
authored
3 years ago
by
William KOCH
Browse files
Options
Downloads
Patches
Plain Diff
Generate cards
parent
da21f26f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/card_deck.rs
+33
-0
33 additions, 0 deletions
src/card_deck.rs
with
33 additions
and
0 deletions
src/card_deck.rs
0 → 100644
+
33
−
0
View file @
ea666df1
use
super
::
prime_gen
;
use
rand
::
thread_rng
;
use
rand
::
seq
::
SliceRandom
;
use
num_bigint
::{
BigUint
};
#[derive(Debug)]
pub
struct
Card
{
p
:
BigUint
,
q
:
BigUint
,
N
:
BigUint
}
pub
fn
gen_card_deck
(
prime_size
:
usize
,
deck_size
:
usize
)
->
Vec
::
<
Box
<
Card
>>
{
let
mut
cards
:
Vec
::
<
Box
<
Card
>>
=
Vec
::
new
();
let
_3
=
BigUint
::
from
(
3u32
);
for
i
in
0
..
deck_size
{
println!
(
"Generating card {}"
,
i
);
// generate p_i, q_i s.t. p_i congruent q_i = 3 mod 4
let
mut
p_i
:
BigUint
;
let
mut
q_i
:
BigUint
;
loop
{
p_i
=
prime_gen
::
gen_prime
(
prime_size
);
q_i
=
prime_gen
::
gen_prime
(
prime_size
);
if
&
p_i
%
4u16
==
_3
&&
&
q_i
%
4u16
==
_3
{
break
;
}
}
let
N
=
&
p_i
*
&
q_i
;
let
c
=
Card
{
p
:
p_i
.clone
(),
q
:
q_i
.clone
(),
N
:
N
.clone
()
};
cards
.push
(
Box
::
new
(
c
));
}
cards
.shuffle
(
&
mut
thread_rng
());
cards
}
\ No newline at end of file
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