Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@joncinque
Copy link
Collaborator

Problem

This is #114, but for secp256r1 instead, removing external types from the public interface.

Summary of changes

This one was a bit more complicated because it uses openssl types, which aren't as straightforward as simple bytes, so it uses bytes encoded in DER as the interface. This seemed like the most standard format from simple web searching, but I'm certainly no expert in this area.

There seemed to also be a lot of vecs in the new instruction implementation, which shouldn't be necessary, so I changed those to arrays.

#### Problem

This is anza-xyz#114, but for secp256r1 instead, removing external types from
the public interface.

#### Summary of changes

This one was a bit more complicated because it uses openssl types, which
aren't as straightforward as simple bytes, so it uses bytes encoded in
DER as the interface. This seemed like the most standard format from
simple web searching, but I'm certainly no expert in this area.

There seemed to also be a lot of vecs in the new instruction
implementation, which shouldn't be necessary, so I changed those to
arrays.
@joncinque joncinque requested a review from samkim-crypto April 4, 2025 13:31
Copy link
Contributor

@samkim-crypto samkim-crypto left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just two minor comments below.


pub fn sign_message(
message: &[u8],
der: &[u8],
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks fine, but should we rename the der variable to priv_key_bytes_der or priv_key_der to be more specific? der can mean an encoding for signatures as well, so it might be worth making it clear from just the function syntax (though we immediately parse as a signing key below).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to me! I went with priv_key_bytes_der

}

assert_eq!(pubkey.len(), COMPRESSED_PUBKEY_SERIALIZED_SIZE);
assert_eq!(signature.len(), SIGNATURE_SERIALIZED_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that the pubkey length check was added above, but the signature length check was removed. Is this intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's correct -- signing_key.public_key().to_bytes() returns Vec<u8>, so we aren't 100% sure the size is correct, whereas sign_message returns [u8; SIGNATURE_SERIALIZED_SIZE], so we already know statically that the size is correct, which means it's unnecessary to check the size.

Copy link
Contributor

@samkim-crypto samkim-crypto left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@joncinque joncinque merged commit a9c2901 into anza-xyz:master Apr 9, 2025
23 checks passed
@joncinque joncinque deleted the noopenssl branch April 9, 2025 12:11
febo pushed a commit to febo/solana-sdk that referenced this pull request Sep 21, 2025
* secp256r1: Deprecate openssl types in public API

#### Problem

This is anza-xyz#114, but for secp256r1 instead, removing external types from
the public interface.

#### Summary of changes

This one was a bit more complicated because it uses openssl types, which
aren't as straightforward as simple bytes, so it uses bytes encoded in
DER as the interface. This seemed like the most standard format from
simple web searching, but I'm certainly no expert in this area.

There seemed to also be a lot of vecs in the new instruction
implementation, which shouldn't be necessary, so I changed those to
arrays.

* Rename variable
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.

2 participants