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

Use hex encoding for JSON instead of raw bytes #61

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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