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

Functions to turn public key into script hash and address #2843

Closed
wants to merge 1 commit into from
Closed

Functions to turn public key into script hash and address #2843

wants to merge 1 commit into from

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 30, 2023

add funtion to turn public key into address. For verification of public key provided for ECDSA verification.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 30, 2023

This is part of #2835

/// <param name="curve">The curve to be used by the ECDSA algorithm.</param>
/// <returns>The computed public key script hash. Zero in case of error.</returns>
[ContractMethod(CpuFee = 1 << 15)]
public static UInt160 PubKeyToScriptHash(byte[] pubKey, NamedCurve curve)
Copy link
Contributor

Choose a reason for hiding this comment

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

System.Contract.CreateStandardAccount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is correct, thank you, will remove this.

/// <param name="version">The version of the address.</param>
/// <returns>The computed address of script hash. Empty in case of error.</returns>
[ContractMethod(CpuFee = 1 << 14)]
public static string ScriptHashToAddr(UInt160 scriptHash, byte version)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd pair this with AddrToScriptHash, although this can be a part of some non-standard library as well (like https://pkg.go.dev/github.com/nspcc-dev/neo-go/pkg/interop@v0.0.0-20230130121057-bd26b9db8307/lib/address).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good one, will try to add it to the compiler

@Jim8y Jim8y closed this Jan 31, 2023
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