Skip to content
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

Improve the README #566

Merged
merged 1 commit into from
May 16, 2023
Merged

Improve the README #566

merged 1 commit into from
May 16, 2023

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Dec 16, 2022

Improve the README files

Improve the secp256k1 readme by:

  • Use a top level markdown header (level 1) Use HTML for header and badges
  • Add a link to the SECG's website (www.secg.org)
  • Add a link for secp256k1 to bitcoin.it explaining the curve

Improve the secp256k1-sys readme by:

  • Use HTML for header and badges (a subset of the badges used in rust-secp256k1 readme)
  • Basic cleanup
    • Use 100 column width
    • Use backticks
    • Use capitals

@tcharding
Copy link
Member Author

Needs #565 to get green CI.

README.md Outdated
`rust-secp256k1` is a wrapper around [libsecp256k1](https://github.com/bitcoin-core/secp256k1),
a C library by Pieter Wuille for producing ECDSA signatures using the SECG curve
`secp256k1`. This library
a C library by Pieter Wuille for producing ECDSA signatures using the [SECG](https://www.secg.org/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"for producing ECDSA signatures" sounds weird since it can also verify them and also produce/verify schnorr signatures and also perform ECDH and also tweak the keys and probably something I forgot.

"a C library implementing various cryptographic functions using the SECG curve secp256k1" might be good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used as suggested, note this removes Peter's name - this seems correct since it does not appear in the readme of libsecp256k1 (I thought I remembered seeing it there before but not sure).

cc @sipa in case he would like the attribution to remain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could say "created by Pieter Wuille". But I agree that we should follow the README, which presumably attributes it to "the bitcoin core developers" or something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I didn't mean to drop attribution but it's a good question which attribution is the correct one.

`--cfg=rust_secp_no_symbol_renaming'` to your `RUSTFLAGS` variable.
If you want to compile this library without using the bundled symbols (which may be required for
integration into other build systems), you can do so by adding `--cfg=rust_secp_no_symbol_renaming'`
to your `RUSTFLAGS` variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add the information about the limitations of this @apoelstra mentioned while we're at it. I think this should be correct. I suggest putting it right after the heading.

Danger: doing this incorrectly may have catastrophic consequences!
This is mainly intended for applications consisting of various programming languages that intend to link the same library to save space or bundles of multiple binaries coming from the same source.
Do not use this to link to a random secp256k1 library you found in your OS!
Packaging the library into a separate distribution package could be done with care.
E.g. in Debian if you'd have libsecp256k1 with version 1.2.3 then all the binaries using it must use >= 1.2.3, << 1.2.4, assuming you will only ever release binary-compatible versions of the package.
This is because there are no binary compatibility guarantees and the library is security-critical.
Note also that unless you're packaging the library for an official repository you should prefix your package and the library with a string specific to you. E.g. if you have a set of packages called my-awesome-packages you should package libsecp256k1 as libmy-awesome-packages-secp256k1 and depend on that library/package name from your application.
If you do any of this you must make sure that either every component that depends on libsecp256k is written to depend on the same version (-sys crate not being duplicated in case of Rust) or that the differing components use static bundled version with the different prefixes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g. in Debian if you'd have libsecp256k1 with version 1.2.3 then all the binaries using it must use >= 1.2.3, << 1.2.4, assuming you will only ever release binary-compatible versions of the package. This is because there are no binary compatibility guarantees and the library is security-critical.

I don't understand this sentence -- there is only one release of libsecp in existence and it is not in any distribution AFAIK. What distributions have actually packaged is random shit. I'm also not sure why, "if there are no binary compatibility guarantees", merely constraining a version number would provide any value.

I'm also not totally sure who "you" is here -- is in the author of the Rust code, or a distribution maintainer, or a libsecp developer, or what?

Other than this, this text looks good.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it is not in any distribution AFAIK

Indeed, this is written in case someone wants to package it. But now I'm thinking it may overlooked anyway. I guess some doc like that should go to the upstream library instead.

I'm also not sure why, "if there are no binary compatibility guarantees", merely constraining a version number would provide any value.

If you control all the packages and make sure you won't release version 1.2.3-2 that is binary-incompatible with 1.2.3-1 then it's OK to update the library. (e.g. if you only made cosmetic changes like documentation or fixed something minor inside a function body)

Basically, if you control the library (package) and make sure it doesn't get confused/swapped with something else then it's OK to link to it from a binary you control.

I'm also not totally sure who "you" is here

The author of the binary using libsecp256k1 and potentially distribution maintainer. (I think they are sometimes the same person? I do make my own packages for some of my own projects but that doesn't make me distribution maintainer...)

Copy link
Member

@apoelstra apoelstra Dec 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about If you are packaging software that depends on rust-secp256k1, using this flag to link to another package, make sure you stay within the binary compatibility guarantees of that package. For example, in Debian if you need libsecp256k1 1.2.3, make sure your package requires a version strictly >= 1.2.3 << 1,2.4.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

This crate provides Rust definitions for the FFI structures and methods.
[Full documentation](https://docs.rs/secp256k1_sys/)

This is the Foreign Function Interface (FFI) to the [libsecp256k1](https://github.com/bitcoin-core/secp256k1) library.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit strange the library is not FFI. The library just provides low-level bindings to the C FFI exposed by libsecp256k1

[Full documentation](https://docs.rs/secp256k1_sys/)

This is the Foreign Function Interface (FFI) to the [libsecp256k1](https://github.com/bitcoin-core/secp256k1) library.
Provides bindings (structures and methods) in Rust for interfacing with `libsecp256k1` in a typesafe manner.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -sys crate is not type safe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could drop the "in a typesafe manner" clause, but in fairness, the bindings are typesafe in that they enforce that you use the correct C types, correct number of arguments to functions, etc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you use the correct C types

That's questionable at best. If you happen to be on a platform that defines c_int as i32 and you accidentally hard-code i32 in the code your code suddenly becomes non-portable to platforms that have c_int be a different type (presumably i16 or i64.

They are "sort of safe" yes.

@tcharding tcharding force-pushed the 12-16-readme branch 2 times, most recently from 0b3e9cb to 791def3 Compare December 20, 2022 00:08
@tcharding
Copy link
Member Author

Force push attempts to implement suggestions, will require close review please.

software that depends on `rust-secp256k1`, using this flag to link to another package, make sure you
stay within the binary compatibility guarantees of that package. For example, in Debian if you need
`libsecp256k1 1.2.3`, make sure your package requires a version strictly`>= 1.2.3 << 1.2.4`. This is
because there are no binary compatibility guarantees and the library is security-critical. Note also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the This is because line doesn't make sense, and should be removed.

that unless you're packaging the library for an official repository you should prefix your package
and the library with a string specific to you. E.g. if you have a set of packages called
`my-awesome-packages` you should package `libsecp256k1` as `libmy-awesome-packages-secp256k1` and
depend on that library/package name from your application. If you do any of this you must make sure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we should drop "If you do any of this..." since it's redundant with the existing warnings and isn't very clear.

@tcharding
Copy link
Member Author

Force pushed suggested changes.

apoelstra
apoelstra previously approved these changes Dec 20, 2022
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a13297a

@apoelstra
Copy link
Member

Will let @Kixunil review the current text before merging.

@tcharding
Copy link
Member Author

Friendly bump when you get a chance please @Kixunil.

@tcharding
Copy link
Member Author

Rebase only.


- Where `<version-code>` is the secp256k1-sys version number underscored: `0_1_2`.
- Where `<rev>` is the git revision of `libsecp256k1` to checkout. If you do not specify a revision,
the script will simply clone the repo and use whatever revision the default branch is pointing to.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 04f2c24:

The new text is now different (and incorrect) where before I think it was just a reflow of the old text.

@tcharding
Copy link
Member Author

GitHub actions seem to be borked

  • Only "Cross testing" is running
  • WASM test is broken
[Invalid workflow file: .github/workflows/rust.yml#L117](https://github.com/rust-bitcoin/rust-secp256k1/actions/runs/4938183432/workflow)
The workflow is not valid. .github/workflows/rust.yml (Line: 117, Col: 15): Unrecognized named-value: 'matrix'. Located at position 1 within expression: matrix.toolchain

@tcharding tcharding force-pushed the 12-16-readme branch 3 times, most recently from c195600 to b7e667d Compare May 15, 2023 22:44
Improve the secp256k1 readme by:

- Use a top level markdown header (level 1)
- Add a link to the SECG's website (www.secg.org)
- Add a link for `secp256k1` to bitcoin.it explaining the curve

Improve the secp256k1-sys readme by:

- Mirror secp256k1 readme badges, heading, docs link
- Basic cleanup
 - Use 100 column width
 - Use backticks
 - Use capitals
@tcharding
Copy link
Member Author

Changes in force push:

  • Fixed rebase issue flagged during review
  • Added HTML (incl. badges) as we do in rust-bitcoin (this uncovered the fact that CI is broken at the moment, WIN!)

@tcharding
Copy link
Member Author

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 47aa740

@apoelstra apoelstra merged commit 7c8270a into rust-bitcoin:master May 16, 2023
@apoelstra
Copy link
Member

Oops, I forgot we were gating this one on @Kixunil. But I think the text is definitely an improvement over the existing text in any case.

@Kixunil
Copy link
Collaborator

Kixunil commented May 16, 2023

No problem, looks fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants