Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
teaching
dunixir
Commits
ec274719
Commit
ec274719
authored
4 years ago
by
x18zhan2
Browse files
Options
Downloads
Patches
Plain Diff
index on dev:
07396eae
WIP on dev:
f6440af4
Delete README.md
parent
07396eae
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/block/validation/local/identity_signaure.ex
+53
-0
53 additions, 0 deletions
lib/block/validation/local/identity_signaure.ex
lib/block/validation/local/universal_dividend.ex
+7
-0
7 additions, 0 deletions
lib/block/validation/local/universal_dividend.ex
with
60 additions
and
0 deletions
lib/block/validation/local/identity_signaure.ex
0 → 100644
+
53
−
0
View file @
ec274719
defmodule
Block
.
Validation
.
Local
.
IdentitySignature
do
require
Logger
@default_document_version
10
def
valid
(
block
)
do
identities
=
block
[
"identities"
]
not
is_wrong_sig
(
identities
,
block
[
"currency"
])
end
defp
is_wrong_sig
(
identities
,
currency
)
do
case
length
(
identities
)
do
0
->
false
_
->
[
identity
|
tail
]
=
identities
[
pubkey
,
sig
,
buid
,
uid
]
=
String
.
split
(
identity
,
":"
)
idty
=
%{
"version"
=>
@default_document_version
,
"currency"
=>
currency
,
"pubkey"
=>
pubkey
,
"sig"
=>
sig
,
"buid"
=>
buid
,
"uid"
=>
uid
}
if
not
Crypto
.
verify_digital_signature
(
sig
,
get_idty_raw_without_sig
(
idty
),
pubkey
)
do
Logger
.
error
(
"Identity's signature must match"
)
true
else
is_wrong_sig
(
tail
,
currency
)
end
end
end
defp
get_idty_raw_without_sig
(
identity
)
do
""
<>
"Version: "
<>
to_string
(
identity
[
"version"
])
<>
"
\n
"
<>
"Type: Identity
\n
"
<>
"Currency: "
<>
identity
[
"currency"
]
<>
"
\n
"
<>
"Issuer: "
<>
identity
[
"pubkey"
]
<>
"
\n
"
<>
"UniqueID: "
<>
identity
[
"uid"
]
<>
"
\n
"
<>
"Timestamp: "
<>
identity
[
"buid"
]
<>
"
\n
"
end
end
This diff is collapsed.
Click to expand it.
lib/block/validation/local/universal_dividend.ex
0 → 100644
+
7
−
0
View file @
ec274719
defmodule
Block
.
Validation
.
Local
.
UniversalDividend
do
def
valid
(
block
)
do
block
[
"number"
]
===
0
and
block
[
"dividend"
]
===
nil
end
end
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