Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
6b1153d9
Commit
6b1153d9
authored
7 years ago
by
Gav
Browse files
Options
Downloads
Patches
Plain Diff
Add ed25519_verify external.
parent
ae5e497e
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/executor/src/wasm_executor.rs
+19
-0
19 additions, 0 deletions
substrate/executor/src/wasm_executor.rs
substrate/primitives/src/ed25519.rs
+22
-0
22 additions, 0 deletions
substrate/primitives/src/ed25519.rs
with
41 additions
and
0 deletions
substrate/executor/src/wasm_executor.rs
+
19
−
0
View file @
6b1153d9
...
...
@@ -27,6 +27,7 @@ use error::{Error, ErrorKind, Result};
use
wasm_utils
::{
MemoryInstance
,
UserDefinedElements
,
AddModuleWithoutFullDependentInstance
};
use
tiny_keccak
;
use
primitives
::
ed25519
;
struct
Heap
{
end
:
u32
,
...
...
@@ -148,6 +149,24 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
[
0
;
32
]
};
let
_
=
this
.memory
.set
(
out
,
&
result
);
},
ext_ed25519_verify
(
msg_data
:
*
const
u8
,
msg_len
:
u32
,
sig_data
:
*
const
u8
,
pubkey_data
:
*
const
u8
)
->
u32
=>
{
(||{
let
mut
sig
=
[
0u8
;
64
];
if
let
Err
(
_
)
=
this
.memory
.get_into
(
sig_data
,
&
mut
sig
[
..
])
{
return
0
;
};
let
mut
pubkey
=
[
0u8
;
32
];
if
let
Err
(
_
)
=
this
.memory
.get_into
(
pubkey_data
,
&
mut
pubkey
[
..
])
{
return
0
;
};
if
let
Ok
(
msg
)
=
this
.memory
.get
(
msg_data
,
msg_len
as
usize
)
{
if
ed25519
::
Signature
::
from
(
sig
)
.verify
(
&
msg
,
&
ed25519
::
Public
::
from
(
pubkey
))
{
1
}
else
{
0
}
}
else
{
0
}
})()
}
=>
<
'e
,
E
:
Externalities
+
'e
>
);
...
...
This diff is collapsed.
Click to expand it.
substrate/primitives/src/ed25519.rs
+
22
−
0
View file @
6b1153d9
...
...
@@ -26,6 +26,28 @@ pub struct Pair(signature::Ed25519KeyPair);
#[derive(Clone)]
pub
struct
Signature
([
u8
;
64
]);
impl
Signature
{
pub
fn
from
(
data
:
[
u8
;
64
])
->
Self
{
Signature
(
data
)
}
pub
fn
from_slice
(
data
:
&
[
u8
])
->
Self
{
let
mut
r
=
[
0u8
;
64
];
r
.copy_from_slice
(
data
);
Signature
(
r
)
}
}
impl
Public
{
pub
fn
from
(
data
:
[
u8
;
32
])
->
Self
{
Public
(
data
)
}
pub
fn
from_slice
(
data
:
&
[
u8
])
->
Self
{
let
mut
r
=
[
0u8
;
32
];
r
.copy_from_slice
(
data
);
Public
(
r
)
}
}
impl
Pair
{
/// Generate new secure (random) key pair.
pub
fn
new
()
->
Pair
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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