Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cesium2s
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
Service Desk
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
clients
Cesium-grp
cesium2s
Commits
beb26280
Commit
beb26280
authored
2 years ago
by
bl05b3e
Browse files
Options
Downloads
Patches
Plain Diff
[enh] Account: add SCRYPT_PARAMS const
parent
d4837a66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/wallet/account.service.ts
+33
-7
33 additions, 7 deletions
src/app/wallet/account.service.ts
with
33 additions
and
7 deletions
src/app/wallet/account.service.ts
+
33
−
7
View file @
beb26280
...
@@ -48,6 +48,36 @@ export interface LoadAccountDataOptions {
...
@@ -48,6 +48,36 @@ export interface LoadAccountDataOptions {
emitEvent
?:
boolean
;
emitEvent
?:
boolean
;
}
}
export
const
SCRYPT_PARAMS
=
{
SIMPLE
:
<
Params
>
{
N
:
2048
,
r
:
8
,
p
:
1
},
DEFAULT
:
<
Params
>
{
N
:
4096
,
r
:
16
,
p
:
1
},
SECURE
:
<
Params
>
{
N
:
16384
,
r
:
32
,
p
:
2
},
HARDEST
:
<
Params
>
{
N
:
65536
,
r
:
32
,
p
:
4
},
EXTREME
:
<
Params
>
{
N
:
262144
,
r
:
64
,
p
:
8
}
};
const
ED25519_SEED_LENGTH
=
32
;
@
Injectable
({
providedIn
:
'
root
'
})
@
Injectable
({
providedIn
:
'
root
'
})
export
class
AccountService
extends
StartableService
{
export
class
AccountService
extends
StartableService
{
...
@@ -545,18 +575,14 @@ export class AccountService extends StartableService {
...
@@ -545,18 +575,14 @@ export class AccountService extends StartableService {
this
.
_$accounts
.
next
(
this
.
_$accounts
.
value
.
slice
()
/*create a copy*/
);
this
.
_$accounts
.
next
(
this
.
_$accounts
.
value
.
slice
()
/*create a copy*/
);
}
}
async
addV1Account
(
data
:
{
salt
:
string
,
password
:
string
;
meta
?:
AccountMeta
}):
Promise
<
Account
>
{
async
addV1Account
(
data
:
{
salt
:
string
,
password
:
string
;
meta
?:
AccountMeta
,
scryptParams
?:
Params
}):
Promise
<
Account
>
{
if
(
!
data
?.
salt
||
!
data
?.
password
)
return
;
if
(
!
data
?.
salt
||
!
data
?.
password
)
return
;
console
.
info
(
this
.
_logPrefix
+
'
Authenticating using salt+pwd...
'
);
console
.
info
(
this
.
_logPrefix
+
'
Authenticating using salt+pwd...
'
);
const
passwordU8a
=
Uint8Array
.
from
(
data
.
password
.
split
(
''
).
map
(
x
=>
x
.
charCodeAt
(
0
)));
const
passwordU8a
=
Uint8Array
.
from
(
data
.
password
.
split
(
''
).
map
(
x
=>
x
.
charCodeAt
(
0
)));
const
saltU8a
=
Uint8Array
.
from
(
data
.
salt
.
split
(
''
).
map
(
x
=>
x
.
charCodeAt
(
0
)));
const
saltU8a
=
Uint8Array
.
from
(
data
.
salt
.
split
(
''
).
map
(
x
=>
x
.
charCodeAt
(
0
)));
const
result
=
scryptEncode
(
passwordU8a
,
saltU8a
,
<
Params
>
{
const
result
=
scryptEncode
(
passwordU8a
,
saltU8a
,
data
.
scryptParams
||
SCRYPT_PARAMS
.
DEFAULT
);
N
:
4096
,
const
seedHex
=
u8aToHex
(
result
.
password
.
slice
(
0
,
ED25519_SEED_LENGTH
));
r
:
16
,
p
:
1
});
const
seedHex
=
u8aToHex
(
result
.
password
.
slice
(
0
,
32
));
//console.debug('Computed seed (hex) from salt+pwd:', rawSeedString);
//console.debug('Computed seed (hex) from salt+pwd:', rawSeedString);
...
...
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