-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch seed / RNG / attestation / user keys / appname / appversion from env at startup then stick with it #440
Conversation
4652362
to
6ad8ca1
Compare
1ab4095
to
74f578a
Compare
I hold this PR for some time as I'm going to have a very similar issue with the RNG. |
@lpascal-ledger In that case, there is also app name and version which could be handled similarly. |
a7eb578
to
a035081
Compare
319c98e
to
1ab369b
Compare
@xchapron-ledger This can be reviewed, I'm going to add unit tests but that's functionally ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this now noisy log: https://github.com/LedgerHQ/speculos/blob/master/src/bolos/cx_ec.c#L1655
The launch output of Speculos get mixed info. I'm wondering if we can do something simple to fix it to ease readability? |
What's bothering you? Given the tool and the amount of features, it still seems reasonable to me. We could drop "default" lines such as As some logs comes from the Python server(s?) which are asynchronous vs. the emulator, it's hard to manage some of the logs order. |
8e9897d
to
523bc97
Compare
The fact that there are lines starting with |
Right I see. |
Adding all this crypto stuff may have slowed the emulator startup enough for the Flask API to catchup and log on top of it, so this may be more mixed than it was. |
Yeap, not sure that postponing is a good thing. This will slow test everywhere... |
I'd say, let's remove logs that are mostly non necessary, so that output stay relevant, and let's merge. |
b253aa4
to
73a4ade
Compare
I've dropped quite some logs. Smaller, yet mixed up. There's no logging mechanism in the emulator, only And TBH, most of the logs here are not that interesting: either the values are the default one, and you can easily get them from the code if needed, or the user set them through the environment, and in this case it probably already has them in a variable or something. |
…ment after cxlib is loaded
73a4ade
to
fccb51c
Compare
Feature 1
Previously, seed, RNG and app name & version were fetched from the environment each time they were needed.
When several Speculos instances runs simultaneously in the same shell, the last declared env variable would overwrite the environment variable for every Speculos instance, and thus every Speculos instances would use the same value (same seed, same RNG, same app name / version).
Now these information are fetched once when Speculos starts, and stored internally. Successive Speculos instances no longer overwrite these information for former Speculos instances which are still running.
Feature 2
Attestation key and user private keys were not configurable.
Now they can be.
Implementation
These features are implemented in a
environment.c
module which embeds static variables to stores these values.This module exposes an
init_environment
function, which is called at the start of Speculos (early inlauncher.c:main
, before the emulator is properly started). This function fetches, checks and sets the variables from the environment, or keeps them with their default values if they are not defined.Module which need these values (
bolos/endorsement.c
,bolos/cx.c
,bolos/os.c
,bolos/os_eip2333.c
andbolos/os_bip32.c
) can useenv_get_[seed|rng|user_private_key|user_certificate|app_tag]
to access them.