Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
a2834dc1
Unverified
Commit
a2834dc1
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
KeyPair : add verify method
parent
1ac89c33
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
Resolve "Add keyPair type"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
keys/ed25519.rs
+6
-2
6 additions, 2 deletions
keys/ed25519.rs
keys/lib.rs
+4
-1
4 additions, 1 deletion
keys/lib.rs
with
10 additions
and
3 deletions
keys/ed25519.rs
+
6
−
2
View file @
a2834dc1
...
...
@@ -29,7 +29,7 @@ use base64;
use
base64
::
DecodeError
;
use
crypto
;
use
super
::{
BaseConvertionError
,
PrivateKey
as
PrivateKeyMethods
};
use
super
::{
BaseConvertionError
,
PrivateKey
as
PrivateKeyMethods
,
PublicKey
as
PublicKeyMethods
};
/// Store a ed25519 signature.
#[derive(Clone,
Copy)]
...
...
@@ -250,6 +250,10 @@ impl super::KeyPair for KeyPair {
fn
sign
(
&
self
,
message
:
&
[
u8
])
->
Signature
{
self
.private_key
()
.sign
(
message
)
}
fn
verify
(
&
self
,
message
:
&
[
u8
],
signature
:
&
Self
::
Signature
)
->
bool
{
self
.public_key
()
.verify
(
message
,
signature
)
}
}
/// Keypair generator with given parameters for `scrypt` keypair function.
...
...
@@ -453,6 +457,6 @@ Timestamp: 0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
"
;
let
sig
=
keypair
.sign
(
message
.as_bytes
());
assert!
(
keypair
.
pubkey
.
verify
(
message
.as_bytes
(),
&
sig
));
assert!
(
keypair
.verify
(
message
.as_bytes
(),
&
sig
));
}
}
This diff is collapsed.
Click to expand it.
keys/lib.rs
+
4
−
1
View file @
a2834dc1
...
...
@@ -163,6 +163,9 @@ pub trait KeyPair: Clone + Display + Debug + PartialEq + Eq {
/// Get `PrivateKey`
fn
private_key
(
&
self
)
->
Self
::
PrivateKey
;
/// Sign a message with privkey.
/// Sign a message with priv
ate
key.
fn
sign
(
&
self
,
message
:
&
[
u8
])
->
Self
::
Signature
;
/// Verify a signature with public key.
fn
verify
(
&
self
,
message
:
&
[
u8
],
signature
:
&
Self
::
Signature
)
->
bool
;
}
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