Show / Hide Table of Contents

Class PreSharedKey

A secret (symmetric) key shared among some entities.

Inheritance
Object
PreSharedKey
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: PeerTalk.Cryptography
Assembly: PeerTalk.dll
Syntax
public class PreSharedKey
Remarks

This is specifically used for nodes in a private network.

Properties

| Improve this Doc View Source

Length

The length of the key's value.

Declaration
public int Length { get; }
Property Value
Type Description
Int32

The length in bits.

| Improve this Doc View Source

Value

The key value.

Declaration
public byte[] Value { get; set; }
Property Value
Type Description
Byte[]

The value as a byte array.

Methods

| Improve this Doc View Source

Export(TextWriter, String)

Write the key to text stream.

Declaration
public void Export(TextWriter text, string format = "base16")
Parameters
Type Name Description
TextWriter text

A text writer.

String format

Determines how the key Value is formatted. Can be "base16" or "base64". Defaults to "base16".

Remarks

The key is writen as three lines (1) the codec name "/key/swarm/psk/1.0.0/" (2) the base encoding "/base16/" or "/base64/", (3) the key value in the base encoding

| Improve this Doc View Source

Fingerprint()

Gets an ID for the key.

Declaration
public byte[] Fingerprint()
Returns
Type Description
Byte[]

A byte array that can be used as an identifier for the key.

Remarks

C# implementation of the GO code at https://github.com/libp2p/go-libp2p-pnet/blob/bed5e6afdf9099121029f6fb675be12a50196114/fingerprint.go#L10.

| Improve this Doc View Source

Generate(Int32)

Generate a new value of the specified length.

Declaration
public PreSharedKey Generate(int length = 256)
Parameters
Type Name Description
Int32 length

The length in bits of the new key value, defaults to 256.

Returns
Type Description
PreSharedKey

this for a fluent design.

| Improve this Doc View Source

Import(TextReader)

Read the key from the text stream.

Declaration
public void Import(TextReader text)
Parameters
Type Name Description
TextReader text

A text reader.

See Also

https://github.com/libp2p/specs/blob/master/pnet/Private-Networks-PSK-V1.md
  • Improve this Doc
  • View Source
Back to top Generated by DocFX