Skip to content

Update the ethToSwarmAddress implementation #884

@Aviksaikat

Description

@Aviksaikat

Overview

The current ethToSwarmAddress implementation is outdated as it's not taking the factor of nonce.

How can be fixed

  • Here is the correct implementation in bee.
// NewOverlayFromEthereumAddress constructs a Swarm Address for an Ethereum address.
func NewOverlayFromEthereumAddress(ethAddr []byte, networkID uint64, nonce []byte) (swarm.Address, error) {

	netIDBytes := make([]byte, 8)

	binary.LittleEndian.PutUint64(netIDBytes, networkID)

	data := append(ethAddr, netIDBytes...)
	data = append(data, nonce...)
	h, err := LegacyKeccak256(data)
	if err != nil {
		return swarm.ZeroAddress, err
	}
	return swarm.NewAddress(h[:]), nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4Very low prioritydif:easySomeone with a little familiarity can pick upkind:enhancementA net-new feature or an improvement to an existing featuretype:issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions