Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Use hex values for JSON instead of raw bytes (#61)
Browse files Browse the repository at this point in the history
Signed-off-by: bytemare <[email protected]>
  • Loading branch information
bytemare authored Jun 15, 2024
1 parent cb2d61f commit ef66054
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/licence-header.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPDX-License-Identifier: MIT

Copyright (C) 2020-2023 Daniel Bourdrez. All Rights Reserved.
Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree or at
Expand Down
4 changes: 2 additions & 2 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ func (e *Element) DecodeHex(h string) error {

// MarshalJSON marshals the element into valid JSON.
func (e *Element) MarshalJSON() ([]byte, error) {
return e.Encode(), nil
return []byte(e.Hex()), nil
}

// UnmarshalJSON unmarshals the input into the element.
func (e *Element) UnmarshalJSON(data []byte) error {
return e.Decode(data)
return e.DecodeHex(string(data))
}

// MarshalBinary returns the compressed byte encoding of the element.
Expand Down
4 changes: 2 additions & 2 deletions scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ func (s *Scalar) DecodeHex(h string) error {

// MarshalJSON marshals the scalar into valid JSON.
func (s *Scalar) MarshalJSON() ([]byte, error) {
return s.Encode(), nil
return []byte(s.Hex()), nil
}

// UnmarshalJSON unmarshals the input into the scalar.
func (s *Scalar) UnmarshalJSON(data []byte) error {
return s.Decode(data)
return s.DecodeHex(string(data))
}

// MarshalBinary implements the encoding.BinaryMarshaler interface.
Expand Down

0 comments on commit ef66054

Please sign in to comment.